Created
January 27, 2011 22:41
Auto Invoke Closure - No moving function around...
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
<?php | |
$json = new stdClass(); | |
$json->states = function(){ | |
$array = array(); | |
foreach($db->get_states() as $state) | |
{ | |
$array[] = $state; | |
} | |
return $array; | |
}; | |
echo json_encode($json); | |
/* Outputs {'states' : ['Utah', 'California', 'New York']} */ |
Author
iammerrick
commented
Jan 27, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment