2 回答

TA貢獻1963條經驗 獲得超6個贊
您可以通過這樣的 foreach 一起掃描兩個數組
if(!empty($highlights)) {
foreach(array_map(null, $highlights['highlights_title'], $highlights['highlights_description'])
as list($title, $desc)) {
echo $title.'\t'.$desc."<\br>\n";
}
}

TA貢獻1845條經驗 獲得超8個贊
您有第二個 json_encode 內容,因此:
$data = '{"title":"Property Highlights","description":"Extensive upgrades and thorough maintenance have kept this home in prime condition. Hardwood floors and new carpets create a very comfortable living space.","content":"{\"highlights_title\":[\"Quiet Neighbourhood\",\"Fabulous views\",\"Great local community\",\"Large play center in yard\"],\"highlights_description\":[\"Enjoy tranquil and relaxed atmosphere of the place\",\"Get yourself surrounded by the stunning view opening\",\"You will be delighted by the fantastic local community\",\"Your kids will be happy having all these things around\"]}","module_tag":"div","bootstrap_size":"0","header_tag":"h3","header_class":"","style":"0"}';
$highlights = json_decode($data, true);
var_dump($highlights);
if (!empty($highlights)) {
$content = json_decode($highlights["content"], true);
foreach($content as $subcontent){
foreach($subcontent as $value){
echo $value . "<br/>";
}
}
}
- 2 回答
- 0 關注
- 164 瀏覽
添加回答
舉報