php multidimensional array to single dimension array

<?php 

php convert multidimensional array to single dimension array

convert multidimensional array to single array php



function multidimensional_array_to_single_dimension_array($array) { 
   if (!
$array) return false;
   
$flat = array();
   
$iterator  = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
  
   foreach (
$iterator as $value$singhal[] = $value;
   return 
$singhal;
}
$arr=array(1,2,array(4,5),6,array(7,8,array(9,10,11,array(12,13,14))));

 
 
print_r(multidimensional_array_to_single_dimension_array($arr)); ?>



OUTPUT:

Array ( [0] => 1 [1] => 2 [2] => 4 [3] => 5 [4] => 6 [5] => 7 [6] => 8 [7] => 9 [8] => 10 [9] => 11 [10] => 12 [11] => 13 [12] => 14 )


Comments

  1. Touche. Solid arguments. Keep up the amazing spirit.

    ReplyDelete
  2. I have read so many articles or reviews on the topic
    of the blogger lovers but this article is actually a good piece of writing, keep it up.

    ReplyDelete
  3. Expert plastic extrusion companies serve the vital function of creating specific shapes out of hard plastic that are used to make various other products like
    tubing, casing, and more. The twist should also be
    built to meet a given style of die. Extruders may be divided into three general types :.

    ReplyDelete

Post a Comment

If you Satisfied , Please Leave a comment

Popular posts from this blog

Call PHP Function In JavaScript Using Ajax

List of Post Category Wise in wordpress