How to echo this using foreach()?

Hi guys

I have this array with object below,


Array
(
    [0] => stdClass Object
        (
            [email] => admin@admin.com
        )

    [1] => stdClass Object
        (
            [email] => iridion_us@yahoo.com
        )

    [2] => stdClass Object
        (
            [email] => solidcodes@gmail.com
        )

)

Now how do I echo the value emails using foreach?

Actually I can access each email by using this codes below


    $email[0]->email;

But I dunno how to echo all of the emails using foreach()?

Thank you very much in advanced.

You would iterate over each array index like so

var $myArray = array();

foreach ($myArray as $emailAddress) {
    echo $emailAddress->email . '<br>';
}

That’s it, of course $myArray would be your array variable.

@chris

Thanks dude it works!