-1

これまでのところ、私はこれを持っています:

<?php
$obj = json_decode(file_get_contents("URLTOJSONFILEHERE"), true);

$termStr = "WORD TO SEARCHHERE";
$terms = explode(" ", $termStr);

$results = array_filter($obj, function ($x) use ($terms){
    foreach($terms as $term){
        if (stripos($x["label"], $term) ||
            stripos($x["paper_item_id"], $term))
        {
            return true;
        }
    }
    return false;
});

echo print_r($results);

それは正しく行われますが、print_r と json_encode なしでどのように行うことができますか? それをhtmlテーブルに入れる方法はありますか?私が得る結果:

{"103":{"paper_item_id":215,"type":5,"cost":320,"is_member":true,"label":"Life Jacket","prompt":"Life Jacket","layer":3000},"120":{"paper_item_id":232,"type":5,"cost":700,"is_member":true,"label":"Green Suede Jacket","prompt":"Green Suede Jacket","layer":3000},"125":{"paper_item_id":237,"type":5,"cost":700,"is_member":true,"label":"Red Suede Jacket","prompt":"Red Suede Jacket","layer":3000},"126":{"paper_item_id":238,"type":5,"cost":700,"is_member":true,"label":"Pastel Suede Jacket","prompt":"Pastel Suede Jacket","layer":3000},"129":{"paper_item_id":241,"type":5,"cost":700,"is_member":true,"label":"Purple Suede Jacket","prompt":"Purple Suede Jacket","layer":3000}

JSON の最初の数字は何を意味しますか: 103,120 など JSON ファイル形式で表示しないようにするにはどうすればよいですか?

4

1 に答える 1