PHP String to int
intval($string);
Concerned Chipmunk
intval($string);
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.";
?>
s = "123";
echo intval(s); // 123
s = "hello";
echo intval(s); //0
$num = "3.14";
$int = (int)$num;//string to int
$float = (float)$num;//string to float
$num = intval("10");
$num = floatval("10.1");
phpCopy<?php
$variable = "abc";
$integer = (int)$variable;
echo "The variable has converted to a number and its value is $integer.";
?>