Here are my two arrays. Array cart has a reference to array ship. (BTW the data is not coming from a database)
$z[ship][0] = array("name" => 'Billy',"addy" => '123 this street');
$z[ship][1] = array("name" => 'Bob',"addy" => '123 that street');
$z[ship][2] = array("name" => 'Joe', "addy" => '123 USA street');
$z[ship][3] = array("name" => 'John',"addy" => '123 Reo street');
$z[ship][999] = array("name" => 'Sally',"addy" => '321 Your street');
$z[cart][] = array("pid" => '10',"name" => 'apples',"ship" => '1');
$z[cart][] = array("pid" => '20',"name" => 'oranges',"ship" => '3');
$z[cart][] = array("pid" => '50',"name" => 'Ruger', "ship" => '0');
$z[cart][] = array("pid" => '30',"name" => 'Cherry',"ship" => '1');
$z[cart][] = array("pid" => '40',"name" => 'Fudge',"ship" => '3');
I need to walk array $z[ship] grabbing the key and then echo values from the arrays where and if the value of $z[cart][][ship] matches the key from $z[ship][] in each loop. I need my output to look something like this..
pid = 50 name = ruger ship = Billy
pid =10 name = apples ship = Bob
pid = 30 name = Cherry ship = Bob
pid = 20 name = oranges ship = John
pid = 40 name = Fudge ship = John
Another way of saying this is that im grouping by key $z[cart][][ship] then outputting
echo 'pid = ' .$z[cart][][pid]. ' name = ' .$z[cart][][name]. ' ship = ' .$z[ship]['$v'][name]. '\n';
So far I've tried different ways of using sort and foreach but still cant make it go right.
Thanks
Gibby