fork download
  1. <?php
  2.  
  3. $item = array(
  4. 'phone' => array(
  5. 'Item' => 'S5',
  6. 'info' => array(
  7. array('seller' => 'John', 'price' => 1800),
  8. array('seller' => 'Mason','price' => 1200),
  9. array('seller' => 'Alex','price' => 1500),
  10. ),
  11. ),
  12. 'Item' => 'iPhone 5',
  13. 'info' => array(
  14. array('seller' => 'Depay', 'price' => 1900),
  15. array('seller' => 'David', 'price' => 1450),
  16. array('seller' => 'Daemon', 'price' => 1600),
  17. )
  18. ),
  19. ),
  20. );
  21.  
  22. foreach($item['phone'] as $key => $price) {
  23.  
  24. foreach($price['info'] as $info => $price2 ) {
  25.  
  26. if ($price2['price'] >= 1500) {
  27.  
  28. unset($item['phone'][$key]['info'][$info]);
  29.  
  30. }
  31. }
  32. }
  33.  
  34. echo "<pre>";
  35. print_r($item);
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
<pre>Array
(
    [phone] => Array
        (
            [0] => Array
                (
                    [Item] => S5
                    [info] => Array
                        (
                            [1] => Array
                                (
                                    [seller] => Mason
                                    [price] => 1200
                                )

                        )

                )

            [1] => Array
                (
                    [Item] => iPhone 5
                    [info] => Array
                        (
                            [1] => Array
                                (
                                    [seller] => David
                                    [price] => 1450
                                )

                        )

                )

        )

)