Lost value of array after if compare
I have this code
where the $etc_id2 is like library or room and $id is book
foreach ($result2 as $rodic1 => $rodic_hodnot1)
foreach ($etc_uloziste as $id => $etc_id)
foreach ($etc_id as $id2 => $etc_id2)
[book] => Array
 => library
 => room
But problem is when i //echo $etc_id2."\n" after if($rodic1 ==$id) i get only  => library.
My question in here is why i cant get  => room . And how can i change mzı code to get it .
Thank you for read my post and help