<?php $array = array('asd'=>"Hello",'World'); $obj = (object)$array; How can I refer to the object to bring the World ?
$obj->1 is this wrong?
<?php $array = array('asd'=>"Hello",'World'); $obj = (object)$array; How can I refer to the object to bring the World ?
$obj->1 is this wrong?
Arrays are converted to object with field names named according to the array keys and their corresponding values, with the exception of numeric keys that will not be available until the object is not iterated .
<?php $array = array('asd'=>"Hello", 'World'); $obj = (object)$array; foreach($obj as $key => $value) { print "$key => $value\n"; } asd => Hello 0 => World $arr = ["\0" => ':-)']; $obj = (object) $arr; $arr = ["\0" => ':-)']; $obj = (object) $arr; it will not be possible to iterate, but you can lead to an array and iterate it. - Yegor BaninThis is not an object, but an array. You can call it like this: $ array [0]
Because for php your record will be like:
array:2 [ "asd" => "Hello", 0 => "World"] Source: https://ru.stackoverflow.com/questions/718406/
All Articles