Hello,
How can I convert a string (e.i. "1) into integer?
Thanks, Assaf
Dear Friend,
try this one
$price="234";
$price=$price+0;
ie add 0 to that string eco $price;
regards bvsureshbabu
$price="234"; $price=$price+0; ie add 0 to that string eco $price;
Sorry but how does this convert a string to integer? First of all be more specific with your question, what do you want to achieve by converting to an integer??
You could do this:
(int) $value = 1;
read the php man page on type casting
http://uk2.php.net/language.types.type-juggling
$foo = "123 thousand"; $bar = (int) $foo; echo $bar; // echos 123
I get a string from date() function so I have $a='12:00' now I use substr and have $a='12'
now I want to check if $a<=12
Assaf
so read what we have written above, and you get
$a = 12; $a = (int) $a; // cast $a to an integer if($a <= 12){ echo "$a is less than or equal to 12"; }
not hard!
adam