Multidimensinal array is the array of arrays. You can store multidimensional array as follows:
$arr=array(
array(1,"demo1","demo2"),
array(1,"demo3","demo4"),
array(1,"demo5","demo6"),
array(1,"demo7","demo8")
);
To traverse a multidimensional array in PHP you can use the following script:
<?php
function get_array_elems($arrResult, $where="array"){
while(list($key,$value)=each($arrResult)){
if (is_array($value)){
get_array_elems($value, $where."[$key]");
}
else {
for ($i=0; $i\n";
}
}
}
}
$arr=array(
array(1,"demo1","demo2"),
array(2,"demo3","demo4"),
array(3,"demo5","demo6"),
array(4,"demo7","demo8")
);
get_array_elems($arr);
?>
0 Comment(s)