twitterfacebookgoogle plusrss feed

Pages

Sunday, June 24, 2012

Display Multidimensional Array

Many newbies don't know how to fetch all the keys and its values from the multidimensional arrays; it is as easy as 1, 2, 3 :) ... lets take a look at the following example

 array(
   "sencond_ele_arr_item1","sencond_ele_arr_item2","sencond_ele_arr_item3"
  ),
  "third_ele"   
  );


foreach($array as $value) {
 if (is_array($value)) {
  foreach($value as $dig_value) {
   echo "-->".$dig_value."
";
  }
 } else {
  echo $value."
";
 }
}


?>

This will be the out put
first_ele
-->sencond_ele_arr_item1
-->sencond_ele_arr_item2
-->sencond_ele_arr_item3
third_ele

1 comments:

comment or ask