Thursday, 15 May 2014

php casting variable to array -



php casting variable to array -

i dealing unusual issue of dealing garbage in iterating through variable has been cast array

$arr = (array)$var; // problem $arr = array($var); // ok

the first method seems work fine on values integers, not strings. there documented difference , php have real casting ?

the problem lavarel 4, database sources, function on line 704

if $var scalar, it's documented both lines same:

for of types: integer, float, string, boolean , resource, converting value array results in array single element index 0 , value of scalar converted. in other words, (array)$scalarvalue same array($scalarvalue).

http://www.php.net/manual/en/language.types.array.php#language.types.array.casting

php arrays casting

No comments:

Post a Comment