[英]Compare Values inside array php
我是Php的新人,下面是我的數組
Array
(
[0] => {"tranc":["2"],"report":["2"],"company":["2"],"facilities":["2"],"area":["1"],"zone":["2"]}
[1] => {"tranc":["2"],"report":["2"],"company":["1"],"facilities":["1"],"area":["1"],"zone":["2"]}
)
我需要比較 Arry[0] 和 Array[1] 並獲取值為“1”的字段並將其存儲在數組中。這個
{"tranc":["2"],"report":["2"],"company":["1"],"facilities":["1"],"area":["1"],"zone":["2"]}
$array = array(
'{"tranc":["2"],"report":["2"],"company":["2"],"facilities":["2"],"area":["1"],"zone":["2"]}',
'{"tranc":["2"],"report":["2"],"company":["1"],"facilities":["1"],"area":["1"],"zone":["2"]}',
);
var_dump($array[1]); // will have the row you want i.e row with key = 1
echo '<br>';
echo '<br>';
var_dump(json_decode($array[1])); // will have the object decoded from the json string.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.