Skip to content

Instantly share code, notes, and snippets.

@whisher
Created July 30, 2013 10:07
Show Gist options
  • Save whisher/6111760 to your computer and use it in GitHub Desktop.
Save whisher/6111760 to your computer and use it in GitHub Desktop.
<?php
$recipes = array(
array(
'id'=> 1,
'title'=>'Cookies1',
'description'=>'Delicious1, crisp on the outside, chewy 1',
'ingredients'=> array(
'amount'=> '1',
'amountUnits'=> 'packet',
'ingredientName'=> 'Chips Ahoy'
),
'instructions'=> '1.1 Go buy a packet of Chips Ahoy'
),
array(
'id'=> 2,
'title'=>'Cookies2',
'description'=>'Delicious2, crisp on the outside, chewy 1',
'ingredients'=> array(
'amount'=> '1',
'amountUnits'=> 'packet',
'ingredientName'=> 'Chips Ahoy'
),
'instructions'=> '2.1 Go buy a packet of Chips Ahoy'
),
array(
'id'=> 3,
'title'=>'Cookies3',
'description'=>'Delicious1, crisp on the outside, chewy 1',
'ingredients'=> array(
'amount'=> '1',
'amountUnits'=> 'packet',
'ingredientName'=> 'Chips Ahoy'
),
'instructions'=> '3.1 Go buy a packet of Chips Ahoy'
),
);
if(isset($_GET['id'])){
foreach($recipes as $recipe){
if($recipe['id'] == $_GET['id']){
$recipes = array($recipe);
break;
}
}
}
echo json_encode($recipes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment