Hocrux Hocrux - 1 year ago 43
PHP Question

Having some problems accessing items in an array

I received an array from another server, but i want to fetch the emails only.

The code:


It shows something like:

When I use:


I shows just one email.

How to fetch all emails ?

Answer Source

You'll need to loop through the returned array in order to fetch all the email addresses.

$emails = array();
foreach($search_result["response"]["results"] as $result) {
    $emails []= $result["collection"]["payer"]["email"];

$emails should contain the data you're after.