Diddling with arrays with numeric string keys

后端 未结 2 1273
名媛妹妹
名媛妹妹 2021-01-24 09:23

To understand why I\'m asking this, read this and the comments under it. Consider the following code:

$obj = new stdClass;
$obj->{10} = \'Thing\';

$objArray          


        
2条回答
  •  有刺的猬
    2021-01-24 10:03

    You can try to remove it with array_splice(), if you know its offset ( foreach (...) { $offset++; ... } ), but storing data in an arrays like this, is really not a good idea. You should convert these objects to array with foreach:

    foreach ( $obj as $key => $value )
        $array[$key] = $value;
    

提交回复
热议问题