這是我的上傳.json文件更大我想顯示的那些值,其中的價格比15.0 laravel
陣列 ( [0] =>數組 ( [ID] => 1 [名稱] =>冰雕塑 [價格] => 12.5 [標籤] =>數組 ( [0] =>冷 [1] =>冰 )
[dimensions] => Array
(
[length] => 7
[width] => 12
[height] => 9.5
)
[warehouselocation] => Array
(
[latitude] => -78.75
[longitude] => 20.4
)
)
[1] => Array
(
[id] => 2
[name] => A blue mouse
[price] => 25.5
[tags] => Array
(
[0] => cold
[1] => ice
)
[dimensions] => Array
(
[length] => 3.1
[width] => 1
[height] => 1
)
[warehouselocation] => Array
(
[latitude] => 54.4
[longitude] => -32.7
)
)
[2] => Array
(
[id] => 2
[name] => A blue mouse
[price] => 25.5
[dimensions] => Array
(
[length] => 3.1
[width] => 1
[height] => 1
)
[warehouselocation] => Array
(
[latitude] => 54.4
[longitude] => -32.7
)
)
[3] => Array
(
[id] => 3
[name] => A Chainsmoker
[price] => 99.5
[tags] => Array
(
[0] => king
[1] => wils
)
[dimensions] => Array
(
[length] => 7.1
[width] => 25
[height] => 7
)
[warehouselocation] => Array
(
[latitude] => 54.4
[longitude] => -32.7
)
)
) 這裏我想只顯示數據大於15.0的數據。 如何顯示使用的foreach在Laravel
`$產品列表=的file_get_contents( 'C:\ XAMPP \ htdocs中\ Laravel \資源\數據\ ProductList.json'); $ data = json_decode($ ProductList,true);
// print_r($ data);
foreach($data as $key => $value) {
if ($key == 'price' && $value > 15)
echo $value;
}
print_r($value);
`
我訪問該文件作爲 $產品列表=的file_get_contents('C :\ XAMPP \ htdocs中\ Laravel \資源\數據\ ProductList.json'); \t $ data = json_decode($ ProductList,true); \t \t print_r($ data); 這是我直接以陣列格式顯示整個文件,但現在我只想顯示價格大於15.0 – Carlos