Created
          February 11, 2018 13:24 
        
      - 
      
 - 
        
Save arvindsvt/c4b9447ac984a5ace931927c82c190d0 to your computer and use it in GitHub Desktop.  
  
    
      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 | |
| function odd($var) | |
| { | |
| // returns whether the input integer is odd | |
| return($var & 1); | |
| } | |
| function even($var) | |
| { | |
| // returns whether the input integer is even | |
| return(!($var & 1)); | |
| } | |
| $array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5); | |
| $array2 = array(6, 7, 8, 9, 10, 11, 12); | |
| echo "Odd :\n"; | |
| print_r(array_filter($array1, "odd")); | |
| echo "Even:\n"; | |
| print_r(array_filter($array2, "even")); | |
| ?> | |
| http://php.net/manual/en/function.array-map.php | |
| <?php | |
| $data = array( | |
| array('id' => 1, 'name' => 'Bob', 'position' => 'Clerk'), | |
| array('id' => 2, 'name' => 'Alan', 'position' => 'Manager'), | |
| array('id' => 3, 'name' => 'James', 'position' => 'Director') | |
| ); | |
| $names = array_map( | |
| function($person) { return $person['name']; }, | |
| $data | |
| ); | |
| print_r($names); | |
| ?> | |
| http://php.net/manual/en/function.array-filter.php | |
| http://php.net/manual/en/function.array-walk-recursive.php | |
| http://php.net/manual/en/function.array-walk.php | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment