I am using is_int function To check Whether The Value i get is int or not My code is
<?php
$a = 3;
if(is_int($a)){
echo "INT";
}else{
echo "STRINIG";
}
Which returns me INT But When it tried Using This code
<?php
$a = "3";
if(is_int($a)){
echo "INT";
}else{
echo "STRINIG";
}
It returns me sting .
So why this happen ?
UPDATE
I have problem in following code Let Suppose i have array As
Array ( [0] => 4 [1] => xxxx )
now i have to fetch String So i do
foreach ($mypreferdservice as $value) {
if(is_int($value)){
echo "Int<br>";
}else{
echo "String";
}
}
So it returns me string So How to solve this problem
$avariable assigned with a string value, its type isstring."3"is a string while3is a int.3and"3"even represented differently. If you read the docs: "To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric()."