You could use array_walk_recursive to go through each element of the array including array elements, but you might be better off using an OOP approach and making objects of the items (and possibly hilding an array inside them) which would make it much more intuitive.
Example of array_walk_recursive:
<?php
$sweet = array('a' => 'apple', 'b' => 'banana');
$fruits = array('sweet' => $sweet, 'sour' => 'lemon');
function test_print($item, $key)
{
echo "$key holds $item
";
}
array_walk_recursive($fruits, 'test_print');
?>
output:
a holds apple
b holds banana
sour holds lemon
An example of a class would be as follows:
class mySubArray
{
public $element1='e';
public $element2='f';
public $element3=array();
public $element4='c';
}
class mySomething
{
public $var1='a';
public $var2='b';
public $var3='c';
public $var4=array();
public $var5='d';
public function __construct()
{
$this->var4= new mySubArray();
$this->var4->element3[0]='g';
$this->var4->element3[0]='3';
}
}
$myObject = new mySomething();
Then you can access the properties as follows:
echo $myObject->var3; // Output: c
echo $myObject->var4->element2; // output: f