function findIntInStr($str=''){
$str = 'abc123';
for($i=0;!empty($str[$i]);$i++)
{
if(is_numeric($str[$i]))
{
return false;
}
}
return true; }
This question was asked by me in an interview. This was my answer, However the interviewer asked me to check the datatype of character without using any built-in function. How can I do that here?
function findIntInStr($str=''){
$str = 'abce234';
for($i=0;!empty($str[$i]);$i++)
{
if((string)(int)$str[$i] === (string)$str[$i] )
{
return false;
}
}
return true;}