ciąg php do int
intval($string);
Concerned Chipmunk
intval($string);
<?php
$string = "56";
$int = intval( $string );
echo $int;
?>
phpCopy<?php
$variable = "53";
$integer = intval($variable);
echo "The variable $variable has converted to a number and its value is $integer.";
echo "\n";
$variable = "25.3";
$float = floatval($variable);
echo "The variable $variable has converted to a number and its value is $float.";
?>
// intval() function to convert
// string into integer
echo intval($num), "\n";
method_1:
intval($string);//for string to integer
floatval($string); //for string to float
method_2:
$int = (int)$string;//string to int
$float = (float)$string;//string to float
$str = "10";
$num = (int)$str;