I wish to fetch values from the following array
echo "<pre>";
print_r($attachments);
echo "</pre>";
Array
(
[0] => Array
(
[is_attachment] =>
[filename] => Desert.jpg
[name] => Desert.jpg
[attachment] =>
)
[1] => Array
(
[is_attachment] => 1
[filename] => Hydrangeas.jpg
[name] => Hydrangeas.jpg
[attachment] =>
)
)
I used this code to fetch the values
foreach($attachments as $value)
{
foreach($value as $values)
{
echo $values[filename];
echo "<br>";
}
}
O/P that i got is
D
D
H
H
The desired o/p should be
Desert.jpg
Hydrangeas.jpg
Can anyone tell where i went wrong
No need of two loops, you can get values from single loop as it's outer loop of [0],[1] etc.
foreach($attachments as $value)
{
echo $value['filename'];
echo "<br>";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With