PHP Help, foreach - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21) +---- Thread: PHP Help, foreach (/showthread.php?tid=27467) |
PHP Help, foreach - Tubby - 12-09-2012 that is the warning i get from this code, Code: <?php i was just trying to make a contact form for my website and that error keeps appearing ! could anyone help me please thanks RE: PHP Help, foreach - Haxalot - 03-18-2013 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: PHP Code: $errors[] = 'error 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. RE: PHP Help, foreach - Excuse - 07-02-2013 Add a Code: { after: Code: as $error) |