While calling an HTTP API i get a string of integers as result. the var_dump of the same is like below
string '249139110' (length=12)
But this string have some invisible characters along with it. I tried the below code
foreach (count_chars($id, 1) as $i => $val) {
echo "<br>There were $val instance(s) of \"" , chr($i) , "\" in the string." . ord($i) . " : " .gettype($i) ;
}
and the result i like below
There were 1 instance(s) of "0" in the string.52 : integer
There were 3 instance(s) of "1" in the string.52 : integer
There were 1 instance(s) of "2" in the string.53 : integer
There were 1 instance(s) of "3" in the string.53 : integer
There were 1 instance(s) of "4" in the string.53 : integer
There were 2 instance(s) of "9" in the string.53 : integer
There were 1 instance(s) of "�" in the string.49 : integer
There were 1 instance(s) of "�" in the string.49 : integer
There were 1 instance(s) of "�" in the string.50 : integer
Please help me to remove these � characters. Thanks in advance.
bin2hexto see what those are. (Perhaps NUL chars). Then trim, cast or regex-whitelist the string to an integer.