그래서 PHP로 JSON 파일을 검색하려고합니다. json 링크 : http://media1.clubpenguin.com/play/en/web_service/game_configs/paper_items.json. 난 그냥 내 웹 서버에 JSON 파일을 넣어. Heres 내 스크립트 :JSON 파일을 읽으시겠습니까?
<?php
$query = $_GET['s'];
$terms = explode(' ', $query);
$results = array();
foreach(file('items.json') as $line) {
$found = true;
foreach($terms as $term) {
if(strpos($line, $term) == false) {
$found = false;
break;
}
}
if($found) {
$results[] = $line;
} else {
}
}
print_r($results);
문제는 내 $ 쿼리 대신에 전체 json 파일을 보여줍니다. 그 문제를 해결하려면 어떻게해야합니까?
[json_decode (http://www.php.net/json_decode은] 당신이 찾고있는 것을 아마도) ("items.json를"'json_decode (file_get_contents을 시도, 사실). ' – Orangepill
아니, 방금 오류 묶음 – Timmy6118CP
검색 할 데이터가 무엇입니까? – Orangepill