Created
          January 27, 2011 22:41 
        
      - 
      
- 
        Save iammerrick/799456 to your computer and use it in GitHub Desktop. 
    Auto Invoke Closure - No moving function around...
  
        
  
    
      This file contains hidden or 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