|
Web Contractors Web Developer Jobs Join Us / Log in Discussion |
Convert string to int or double
Submitted by rimian on Tue, 06/24/2008 - 03:19
Quick and dirty to convert string to integer:
This will be zero if your string starts with an alpha character.
$myval = 0 + $mystring;
int intval ( mixed $var [, int $base ] )
Return an integer value of $var. The default base is 10.
echo intval('238'); //returns 238
float floatval ( mixed $var )
echo floatval('155.36'); //returns 155.36
Removing the currency symbol
$price = '$19.95';
echo floatval(str_replace('$', '', $price)); //returns 19.95
New forum topics
- Freelance Web developer wanted
- Ringtone fatigue
- web developer looking for more project
- PHP website maintenance
- Desk available for hire - Rushcutters Bay location
- ZAMP?
- Don't hack the Drupal Core. Make a patch!
- What to charge for site updates
- Start New Website or CMS business. Business Partner / designer
- Code snippets in Google Search Results
- [syd] Freelance developer - .NET/ PHP/ Actionsctipt / DHTML
- Tester needed
- Freelance SharePoint 2003 / 2007 Consultant
- Joomla and Community Builder Module
- PHP export to CSV


Post new comment