数组循环但不显示值

时间:2018-02-05 03:00:53

标签: php arrays rest api woocommerce

我的数组没有显示值

我的代码

 <?php 
 $line_items= array();
 $line_items=$_GET['line_items'];
 foreach ( $line_items as  $line_item ) {
 $line_item = [
        'quantity' => $line_item['quantity'],     
        'price'=>$line_item['price'],       
 ];
$order_data['line_items'][] = $line_item; 
 }
print_r($order_data);
 ?>

我的输出代码

Array
(
[line_items] => Array
    (
        [0] => Array
            (
                [quantity] =>
                [price] => 
            )

        [1] => Array
            (
                [quantity] =>
                [price] => 
            )

    )

 )

错误? Array未显示此参数的值 ?xy.php line_items [量] [] = 2及line_items [量] [] = 4和; line_items [价格] [] = 4和; line_items [价格] [] = 8

预期产出

 Array
 (
   [line_items] => Array
   (
       [0] => Array
          (
            [quantity] => 2          
            [price] => 4
        )

    [1] => Array
        (
            [quantity] => 4               
            [price] => 8
        )

  )
 )

任何帮助将不胜感激,谢谢

0 个答案:

没有答案