03-18-2013, 12:52 PM
The problem is you're attempting to use the foreach construct upon a string. Even though you assigned the $errors variable to an empty array (and therefore type-casting it to an array), PHP's loose typing enables us to type-juggle our variables. This is exactly what you're doing by assigning the $errors variable to a string. You'll need to change how you're assigning the errors if you'd like to fix your problem:
Because we've used the square brackets upon the $errors variable, we're now inserting a new element into our array, rather than type-juggling it to a string with only one value.
PHP Code:
$errors[] = 'error here';
$errors[] = 'error2 here';
Because we've used the square brackets upon the $errors variable, we're now inserting a new element into our array, rather than type-juggling it to a string with only one value.