我正在尝试做这样的事...... 我有一个像这样的数组结构
Array
(
[0] => stdClass Object
(
[product_id1] => 15
[product_id2] => 14
[product_id3] => 0
[product_id4] => 0
[product_id5] => 0
)
[1] => stdClass Object
(
[product_id1] => 15
[product_id2] => 14
[product_id3] => 0
[product_id4] => 0
[product_id5] => 0
)
)
我希望将其转换为
Array
(
[0] => stdClass Object
(
[0] => 15
[1] => 14
[2] => 0
[3] => 0
[4] => 0
)
[1] => stdClass Object
(
[0] => 15
[1] => 14
[2] => 0
[3] => 0
[4] => 0
)
)
答案 0 :(得分:0)
$new = array_values( (array) $arr[0] );
print_r($new);
加入:
$final_arr = array();
foreach( $arr as $val ) {
$tmpArr = array_values( (array)$val);
$final_arr[] = (object) $tmpArr; //convert to object again
}