php string to int – The Best PHP 3 Examples

php string to int : Today, We want to share with you php string to number.In this post we will show you
php string to decimal
, hear for PHP cast to int we will give you demo and example for implement.In this post, we will learn about Convert PHP String To Intiger Value with an example.

php string to int

Example : 1 Use Type Casting

<?php
$member_number = "2.75";
 
// Cast to integer
$int = (int)$member_number;
echo gettype($int) . "<br>"; // Results: integer
echo $int . "<br>"; // Results: 2
 
// Cast to float
$float = (float)$member_number;
echo gettype($float) . "<br>"; // Results: double
echo $float;
?>

Example : 2 convert string to int in php

php to int

$member_number = "3.14";
$int = (int)$member_number;

Example : 3

string to int php

$market = "10";
$member_number = (int)$market;

I hope you get an idea about php string.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.