Create a gist now

Instantly share code, notes, and snippets.

@Nodws /json
Last active May 4, 2018

What would you like to do?
<?
$id = $_SERVER['QUERY_STRING']; //$_GET[id];
$json = '[
{"title":"trench", "img":"https://i.imgur.com/HoPQJqI.jpg"},
{"title":"coat"}
]';
$mydata = json_decode($json);
foreach ($mydata as $v):
if ($v->title == $id) {
$item = $v->title;
break;
}
endforeach;
echo $item ? "<h2>$item</h2>" : '404';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment