Horje
php string to int Code Example
php string to int
intval($string);
php float to int
$int = intval($float);
Convert a String to a Number in PHP
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.";  
?>
convert string to int php
s = "123";
echo intval(s); // 123

s = "hello";
echo intval(s);	//0
cast string to int php
$num = "3.14"; 
$int = (int)$num;//string to int
$float = (float)$num;//string to float
Convert a String to a Number in PHP
phpCopy<?php  
$variable = "abc";
$integer = (int)$variable;
echo "The variable has converted to a number and its value is $integer.";  
?>




13

Related
php parse json Code Example php parse json Code Example
php artisan make migration Code Example php artisan make migration Code Example
php split string Code Example php split string Code Example
php array has value Code Example php array has value Code Example
composer takes older version of php Code Example composer takes older version of php Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
14