View Single Post
Old 01-21-2013, 11:18 PM   PM User | #6
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,383
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
First thing to check is right from the manual:
foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable.

What things should look like:
PHP Code:
<?php
$prescriptions 
= array('step one''step two''step three''step four');
reset($prescriptions);  // TO MAKE SURE THE ARRAY IS POINTING AT FIRST ELEMENT

foreach ($prescriptions as $prescription) {
    echo 
"Next Value: $prescription<br />\n";
}
?>
Is $prescriptions an array? Is it an object?
sunfighter is offline   Reply With Quote