Easy question ... but here it goes:
I have an array and I need to use the [0] index which represents the id of each user. But I can't seem to get it in a foreach statement.
$emails = $aTools->getUsers();
Below is a print_r of the above array '$emails'.
Array
(
[0] => Array
(
[0] => 72
[1] =>
[2] => email@yahoo.com
)
[1] => Array
(
[0] => 62
[1] =>
[2] => email@gmail.com
)
[2] => Array
(
[0] => 64
[1] =>
[2] => email@gmail.com
)
[3] => Array
(
[0] => 66
[1] =>
[2] => email@yahoo.com
)
)
This is not working
$i = 0;
foreach($emails as $email)
{
echo $email[$i][0];
echo "<br/>";
$i++;
}
Each time u're looping u'll get in $email on the entry table :
Array
(
[0] => 72
[1] =>
[2] => email@yahoo.com
)
Then
Array
(
[0] => 62
[1] =>
[2] => email@gmail.com
)
ETC..
So echo $email[$i][0] can't return the id u want.
$email[0] CAN.
SOLUTION :
foreach($emails as $email)
echo $email[0];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.