Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to access arry of objects in php

I have this result from var_dump($_REQUEST);

array(1) { ["email"]=> array(2) { [0]=> string(15) "email1@example.com" [1]=> string(15) "email2@example.com" } }

How to iterate through the arry so that I can get like this result:

$email[0]=email1@example.com
$email[1]=email2@example.com

Update: Edited the indexes

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Update2:

I used:

$email = $_REQUEST['email'];
var_dump($email);

but now I am getting:

array(2) { [0]=> string(18) "email1@example.com" [1]=> string(18) "email2@example.com" }

>Solution :

$_REQUEST['email'] is the array you want to iterate through.

foreach ($_REQUEST['email'] as $i => $email) {
    $num = $i + 1;
    echo "\$email[$num]=$email<br>";
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading