So I am trying to search through JSON, using strpos for it, but it doesn't for me. I always get that "Items doesn't exist".
Here's the PHP
$getItems = file_get_contents('Items.json');
$decodeItems = json_decode($getItems,true);
//$output = ''.$decodeItems['items'][0]['name'].'';
$output = '';
if(isset($_POST['search'])){
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
foreach($decodeItems['items'] as $data){
if($chance = strpos($data, $searchq) !== FALSE){
if($data['name'] == $chance){
$name = $data['name'];
$output .= "<div>".$name."</div>";
}
}
else{
$output = 'Items no';
}
}
}
Here's the Example JSON
{"img":"-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXU5A1PIYQh5hlcX0nvUOGsx8DdQBJjIAVHubSaIAlp1fb3YihQ-tWglYy0lfjjOr6fxjpQ7MFz373Fodyl0AXh-ENkMWinJ4eXcA8-ZFHUq1K_xum70ZO56oOJlyUgjHI5fA","name":"★ Bowie Knife","assetid":"6442574944","myprice":"155.36","condition":"","originalname":"\u2605 Bowie Knife","inspect":"steam:\/\/rungame\/730\/76561202255233023\/+csgo_econ_action_preview%20S76561198034643020A6442574944D2305887113904442996","special":"0","floatvalue":null,"bitskinsprice":"117.36"}