Flatten multidimensional array using array_map


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $multimap = array(
  2. array("name"=>"value1"),
  3. array("name"=>"value2"),
  4. array("name"=>"value3")
  5. );
  6.  
  7. $flatmap = array_map("array_pop",$multimap);
  8.  
  9. print_r($flatmap);
  10.  
  11. /*
  12. Output:
  13.  
  14. Array
  15. (
  16.   [0] => value1
  17.   [1] => value2
  18.   [2] => value3
  19. )
  20. */

URL: http://www.php.net/manual/en/function.array-map.php#101791

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.