可能重复:
将数组和数组中的对象转换为纯数组
我现在有一个数组,但它被传递给另一个将其转换为对象的函数,尽管它需要是一个标准数组,但它才能工作。我需要将以下对象数组转换为标准数组:
[files] => stdClass Object
(
[1] => stdClass Object
(
[name] => price-my-insurance.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpfmRfyN
[error] => 0
[size] => 911376
)
[2] => stdClass Object
(
[name] => sideshows.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpTamdHy
[error] => 0
[size] => 967656
)
[3] => stdClass Object
(
[name] => the-beer-scale.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpwCmwlW
[error] => 0
[size] => 742219
)
[4] => stdClass Object
(
[name] => the-little-lace.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpFnUuf8
[error] => 0
[size] => 939963
)
[5] => stdClass Object
(
[name] => varrstoen-australia.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpUtWyk1
[error] => 0
[size] => 2204400
)
)
对此:
Array
(
[1] => Array
(
[name] => price-my-insurance.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpfmRfyN
[error] => 0
[size] => 911376
)
[2] => Array
(
[name] => sideshows.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpTamdHy
[error] => 0
[size] => 967656
)
[3] => Array
(
[name] => the-beer-scale.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpwCmwlW
[error] => 0
[size] => 742219
)
[4] => Array
(
[name] => the-little-lace.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpFnUuf8
[error] => 0
[size] => 939963
)
[5] => Array
(
[name] => varrstoen-australia.jpg
[type] => image/jpeg
[tmp_name] => /Applications/MAMP/tmp/php/phpUtWyk1
[error] => 0
[size] => 2204400
)
)
我被困在 foreach 循环上来做到这一点。
编辑: