Hi my question is a little tricky, I got a 3-dimensional array and try to verify the 3rd level value and echo both 1st and 3rd level values. The following is the code example, and my failed approaches.
$myArray=array(
"mySub0" => arrary(
0 => array("mySubSub0" => "1","mySubSub1" => "a"),
1 => array("mySubSub0" => "2","mySubSub1" => "b"),
2 => array("mySubSub0" => "3","mySubSub1" => "b"),
),
"mySub1" => arrary(
0 => array("mySubSub0" => "4","mySubSub1" => "a"),
1 => array("mySubSub0" => "5","mySubSub1" => "a"),
2 => array("mySubSub0" => "6","mySubSub1" => "a"),
),
"mySub2" => arrary(
0 => array("mySubSub0" => "7","mySubSub1" => "a"),
1 => array("mySubSub0" => "8","mySubSub1" => "b"),
2 => array("mySubSub0" => "9","mySubSub1" => "a"),
),
),
Ben "mySubSub1" değeri b olup olmadığını kontrol etmek istiyorum. Evetse, "mySubSub0" değerini ve dizinin ilk düzeyinde ilişkili anahtarı echo. Bu gibi olmalıdır:
mySub0
2
3
mySub2
8
Benim başarısız yaklaşım
foreach ($myArray as $a => $b)
{
foreach ($b as $c)
if($c[mySubSub1]=="b")
{
echo $a
echo $c[mySubSub0];
}
else {
}
}
Sonuç, bir yinelenen mySub0 olacak
mySub0
2
mySub0
3
mySub2
8
Ben "echo $ a" "eğer" dışına taşırsanız
foreach ($myArray as $a => $b)
{
echo $a
foreach ($b as $c)
if($c[mySubSub1]=="b")
{
echo $c[mySubSub0];
}
else {
}
}
sonuç olacaktır
mySub0
2
3
mySub1
mySub2
8
biri istenmeyen "mySub1" a değer b olup olmadığını doğrulamak için yer yok çünkü.
It has bothered my a lot today. I tried to Google but haven't found the right answer. Really hope someone can help me. Thank you in advance