php - ctype_digit - strange behaviour -


i have array, , first 13 values integer.

now, if :

array_push($pos1, 100); 

i'll aspect value 14 integer. in fact, doing :

echo ctype_digit($pos1[12])." - ".ctype_digit($pos1[13]); 

the output 1 -

this print_r, requested :

array ( [0] => 0          [1] => 1          [2] => 2          [3] => 3          [4] => 4          [5] => 5          [6] => 6          [7] => 7          [8] => 8          [9] => 9          [10] => 10          [11] => 11          [12] => 12          [13] => 100 ) 

why?

this (in fact) little bit strange, ctype_digit() strictly requires string

echo ctype_digit((string) $pos1[12])." - ".ctype_digit((string) $pos1[13]); // "1 - 1" 

i dont know, why php doesnt cast string.

however, 1 in output comes type-cast, because ctype_digit() returns boolean

echo true; // "1" echo false; // "" 

Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -