How to convert string to number in PHP?
Could any one tell me how to convert string data to number?
For example:
$Str = "212315"; // convert to 212315
How to convert string to number in PHP?
Could any one tell me how to convert string data to number?
For example:
$Str = "212315"; // convert to 212315
You cast it to an integer.
(int) $Str;
http://php.net/manual/en/language.types.type-juggling.php#language.types.typecasting
To explicitly convert a value to integer, use either the (int) or (integer) casts. However, in most cases the cast is not needed, since a value will be automatically converted if an operator, function or control structure requires an integer argument. A value can also be converted to integer with the intval() function.
you can do several things
$str = "212315";
$int = intval($str);
$int2 = (int) $str;
$int3 = (integer) $str;