Created
January 27, 2011 23:03
-
-
Save iammerrick/799491 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sexy_json() | |
{ | |
$regions = function(){ | |
$array = array(); | |
$regions = new Pod('regions'); | |
$regions->findRecords('name ASC'); | |
while($regions->fetchRecord()) | |
{ | |
array_push($array, $regions->get_field('name')); | |
} | |
return $array; | |
}; | |
$countries = function(){ | |
$array = array(); | |
$countries = new Pod('countries'); | |
$countries->findRecords('name ASC'); | |
while($countries->fetchRecord()) | |
{ | |
array_push($array, $countries->get_field('name')); | |
} | |
return $array; | |
}; | |
$states = function(){ | |
$array = array(); | |
$states = new Pod('states'); | |
$states->findRecords('name ASC'); | |
while($states->fetchRecord()) | |
{ | |
array_push($array, $states->get_field('name')); | |
} | |
return $array; | |
}; | |
$locations = function(){ | |
$array = array(); | |
$locations = new Pod('locations'); | |
$locations->findRecords('name ASC'); | |
while($locations->fetchRecord()) | |
{ | |
$location = new stdClass(); | |
$location->name = $locations->get_field('name'); | |
$location->street = $locations->get_field('street'); | |
$location->city = $locations->get_field('city'); | |
$location->state = $locations->get_field('state'); | |
$location->zip = $locations->get_field('zip'); | |
$location->country = $locations->get_field('country'); | |
$location->phone = $locations->get_field('phone'); | |
array_push($array, $location); | |
} | |
return $array; | |
}; | |
$json = new stdClass(); | |
$json->regions = $regions(); | |
$json->countries = $countries(); | |
$json->states = $states(); | |
$json->locations = $locations(); | |
echo json_encode($json); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment