开发者

How to index an array?

开发者 https://www.devze.com 2022-12-10 04:28 出处:网络
I have a multi dimensional array, like this: array(\'name\' => array(\'title\'=>\'Title\',\'date\'=>\'Created\'))

I have a multi dimensional array, like this:

array('name' => array('title'=>'Title','date'=>'Created'))

I store it as JSON 'array', and when I decode it, I want to reach every item by its number,开发者_JAVA技巧 so I want an indexed array.

How could I solve this in PHP?

Tim


According to your last comment Tim, this would achieve what you asked.. but I'm not sure why you would want this based off your initial question.

$foo = array('name' => array('title'=>'Title','date'=>'Created'));
$bar = array_values($foo);
print_r($bar); // Array ( [0] => Array ( [title] => Title [date] => Created ) ) 
0

精彩评论

暂无评论...
验证码 换一张
取 消