Reputation: 234
I am trying to retrieve the last names of the orders placed.
code:
for ($x = 0; $x < 25; ++$x) {
if (($orders[$x]['paymentStatus'] == 'paid') || ($orders[$x]['paymentIsPost'] == TRUE)) {
echo '<pre>';
print_r($orders[$x]['lastname']);
echo '</pre>';
}
}
question: code is not showing me the first lastname in the array actually the name that is in position $orders[0]. I thought that pre-incrementing the variable like this ++$x like this would solve the problem. To bad thats not the case. Any tips?
Update output:
[1]""
[2]""
[3]""
[4]""
[5]""
Not sharing lastnames, which is also not relevant.
Upvotes: 1
Views: 344
Reputation: 1001
try the following to confirm which element of the array you are displaying (and the value of $x
for($x = 0; $x < 25 ; $x++){
if(($orders[$x]['paymentStatus'] == 'paid') || ($orders[$x]['paymentIsPost'] == true)){
echo '<pre>';
--print_r($orders[$x]['lastname']);
echo '['.$x.']'.$orders[$x]['lastname'];
echo '</pre>';
}
}
Upvotes: 1