I am building an array in loop and the results below it for testing purposes:
PHP Code:
$email_array[]= array(
'email' => $fnd_result->fields['email'],
'name' => $fnd_result->fields['name']
);
//$emailArray
(
[0] => Array
(
[email] => test1@test.com
[name] => test1
)
[1] => Array
(
[email] => test2@test.com
[name] => test2
)
)
$snd_cnt = count($email_array);
then on an event this function is triggered:
PHP Code:
for ($x = 0; $x < $snd_cnt; $x++){
$send_to_name = $email_array[$x]['name'];
$send_to_email = $email_array[$x]['email'];
$email_subject = "Your Forklift Has Arrived!";
// Prepare Text-only portion of message
$text_message = OFFICE_FROM . "\t" . $bname . "\n" .
'As you requested, we are notifying you that we have a new forklift in our inventory' . "\n" ."\n" .
'We added a: ' . "\n" ."\n" .
'Year: ' . $forklift_year . "\n" .
'Make: ' . $forklift_make . "\n" .
'Model: ' . $products_model . "\n" .
'Please visit our website at ojlforklifts.com or call us at (305) 836-4337 ' ."\n" ."\n" ."\n" .
$extra_info['TEXT'];
// Prepare HTML-portion of message
$html_msg['EMAIL_GREETING'] = $email_subject;
$html_msg['EMAIL_WELCOME'] = 'We recieved a Forklift within your specs.';
$html_msg['EMAIL_FIRST_NAME'] = $send_to_name;
$html_msg['EMAIL_MESSAGE_HTML'] = '<table> ' .
'<tr><td>Make: </td> <td>' . $forklift_make . '</td></tr>' .
'<tr><td>Capacity: </td> <td>' . $forklift_capacity . 'Lbs</td></tr>' .
'<tr><td>Fuel: </td> <td>' . $fuelM . '</td></tr>' .
'<tr><td>Tires: </td> <td>' . $tireM . '</td></tr>' .
'<tr><td>Price: </td> <td>' . $products_price . '</td></tr>' .
'<tr><td colspan="2"><img src="http://ojlforklifts.com/images/' . $products_image . '" width="350"/></td></tr>' .
'</table>';
zen_mail($send_to_name, $send_to_email, $email_subject, $text_message, $name, $email_address, $html_msg ,'fork_notify');
}
$send_to_email always returns empty
$send_to_name always returns empty
So the problem is that i cant access the 2 variables in the loop. If I echo $email_array[0]['email'] with the index hardcoded, it will give me the result [email protected], but the minute i put put in a variable for the index, $email_array[$x]['email'], the result is empty.
Can anyone point me in the right direction? I even tried the a while loop and it fails also.
Bookmarks