how to parse json array data in php
<p>I want to parse the JSON array <code>$inputjson</code> data with a loop, with one condition: show only those products which <code>quantity != 0</code></p>

<p>i.e in this case, my output should be like </p>

<pre><code>echo &gt;14516 , 29 //productid, list value
echo  &gt;14517 , 30 //productid, list value
echo &gt;14519 , 32 //productid, list value
</code></pre>

<p>json:</p>

<pre><code>$inputjson="{"14514":{"attributes_values":{"3":"7"},"attributes":[27],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":0,"reference":"2221201701017","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'27'"},"14515":{"attributes_values":{"3":"7,5"},"attributes":[28],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":0,"reference":"2221201702014","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'28'"},"14516":{"attributes_values":{"3":"8"},"attributes":[29],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":1,"reference":"2221201703011","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'29'"},"14517":{"attributes_values":{"3":"8,5"},"attributes":[30],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":2,"reference":"2221201704018","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'30'"},"14518":{"attributes_values":{"3":"9"},"attributes":[31],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":0,"reference":"2221201705015","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'31'"},"14519":{"attributes_values":{"3":"9,5"},"attributes":[32],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":1,"reference":"2221201706012","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'32'"},"14520":{"attributes_values":{"3":"10"},"attributes":[33],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":0,"reference":"2221201707019","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'33'"},"14521":{"attributes_values":{"3":"10,5"},"attributes":[34],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":0,"reference":"2221201708016","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'34'"},"14522":{"attributes_values":{"3":"11"},"attributes":[35],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":0,"reference":"2221201709013","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'35'"},"14523":{"attributes_values":{"3":"11,5"},"attributes":[36],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":0,"reference":"2221201710019","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'36'"},"14524":{"attributes_values":{"3":"12"},"attributes":[37],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":0,"reference":"2221201711016","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'37'"},"14525":{"attributes_values":{"3":"13"},"attributes":[39],"price":0,"specific_price":false,"ecotax":0,"weight":0,"quantity":0,"reference":"2221201712013","unit_impact":"0.00","minimal_quantity":"1","available_date":"","id_image":-1,"list":"'39'"}}";

$inputjson=json_decode($inputjson,true);

$inputjson print_r output:--
 Array
    (
        [14514] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 7
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 27
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 0
                [reference] =&gt; 2221201701017
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '27'
            )

        [14515] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 7,5
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 28
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 0
                [reference] =&gt; 2221201702014
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '28'
            )

        [14516] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 8
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 29
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 1
                [reference] =&gt; 2221201703011
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '29'
            )

        [14517] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 8,5
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 30
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 2
                [reference] =&gt; 2221201704018
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '30'
            )

        [14518] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 9
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 31
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 0
                [reference] =&gt; 2221201705015
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '31'
            )

        [14519] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 9,5
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 32
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 1
                [reference] =&gt; 2221201706012
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '32'
            )

        [14520] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 10
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 33
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 0
                [reference] =&gt; 2221201707019
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '33'
            )

        [14521] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 10,5
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 34
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 0
                [reference] =&gt; 2221201708016
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '34'
            )

        [14522] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 11
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 35
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 0
                [reference] =&gt; 2221201709013
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '35'
            )

        [14523] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 11,5
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 36
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 0
                [reference] =&gt; 2221201710019
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '36'
            )

        [14524] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 12
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 37
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 0
                [reference] =&gt; 2221201711016
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '37'
            )

        [14525] =&gt; Array
            (
                [attributes_values] =&gt; Array
                    (
                        [3] =&gt; 13
                    )

                [attributes] =&gt; Array
                    (
                        [0] =&gt; 39
                    )

                [price] =&gt; 0
                [specific_price] =&gt; 
                [ecotax] =&gt; 0
                [weight] =&gt; 0
                [quantity] =&gt; 0
                [reference] =&gt; 2221201712013
                [unit_impact] =&gt; 0.00
                [minimal_quantity] =&gt; 1
                [available_date] =&gt; 
                [id_image] =&gt; -1
                [list] =&gt; '39'
            )

    )
</code></pre>