1
ネストされた要素では機能しません 第1レベルの要素が出力され、データを含むネストされた配列は読み込まれません。ネストされた要素を持つjsonを解析する
<?php
function removeBomUtf8($s){
if(substr($s,0,3)==chr(hexdec('EF')).chr(hexdec('BB')).chr(hexdec('BF'))){
return substr($s,3);
}else{
return $s;
}
}
$url = "https://denden000qwerty.000webhostapp.com/opportunities.json";
$content = file_get_contents($url);
$clean_content = removeBomUtf8($content);
$decoded = json_decode($clean_content);
while ($el_name = current($decoded)) {
// echo 'total = ' . $el_name->total_items . 'current = ' . $el_name->current_page . 'total = ' . $el_name->total_pages . '<br>' ;
echo ' id = ' . $el_name->data[0]->id . ' title = ' . $el_name->data.title . ' location = ' . $el_name->data.location . '<br>' ;
next($decoded);
}
?>
を反復処理したいあなたが解析したいものは何ですか? –
"data":[{"id":412235、 "title": "私たちは英語を話す"、 "lat": "10.6966159"、 "lng": "-74.8741045"、 "url": "https:// gis .aiesec.org/v2/opportunities/412235 "、" status ":" open "、" current_status ":" open "、" location ":" Sabanalarga、Colombia "、" city ":"Atlántico、Colombia " "プログラム":{"id":1、 "short_name": "GV"}、 "applications_count":54、 "is_favourited":false、 "branch":{"id":321136、 "name": "@UNIATLÃNTICO "、" organization ":etc ... – NormalArs
私は" ID "を取得する必要があります:412235、" title ":"英語を話す "city": "Atlántico、Colombia" – NormalArs