WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Limiting float typing
Categories : PHP Update Picture
Zeev Suraski
Date : Oct 17th 1998
Grade : 1 of 5 (graded 1 times)
Viewed : 2616
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Zeev Suraski
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

> Suppose X = 7394; and you'd like to compute how many megabytes X
>evaluates. You'd probably use X / 1024 which will yield: 7.220703125.
>
> Question is: how can you limit the digits after the period, lets say 3
>digits, so the above answer would be: 7.220 = 7.22.

$M = (float) sprintf("%.2f",$X/1024);

(the float casting is not really necessary).



Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
How to access MS Excel spread sheets from PHP
Categories : PHP, Excel, ODBC, Databases
Password reminder
Categories : PHP, PHP Classes, Databases, MySQL, Mail
Website Engine
Categories : PHP, HTML and PHP, Templates
How to strip non-alpha characters from a string
Categories : Regexps, PHP
PHP Nested Menu Example - Shows how to make a single level nested menu
Categories : PHP, Navigation
ovrimos_close -- Closes the connection to ovrimos
Categories : PHP, PHP Functions, OvrimosSQL
Anti SQL injection-PHP
Categories : PHP, MySQL, Security
Password protection for Phorum 3.1.x with userlevels and log.
Categories : PHP, MySQL, Authentication, Security
This script allows people to add their favorite quotes to your website. This could easily be modified to be a guestbook script or comment page script.
Categories : PHP, Complete Programs, HTML and PHP, Misc
Form Elements Class
Categories : PHP, PHP Classes, Form Processing
Secure Login
Categories : PHP, MySQL, Cookies, Security
Audio-Enable Discussion Boards with this Web-page Audio Recorder / Player!
Categories : PHP Extensions, Java, PHP
Link Submition - Allow your visitors to submit links to the site.
Categories : PHP, Arrays, Filesystem, Beginner Guides
Produces browser-safe strings while preserving HTML tags.
Categories : Strings, HTTP, PHP, HTML and PHP