1

I'm reporting form errors to the user with a nested arrays, because there are different groups to the form and I want to show the errors as such:

        echo "<ul>\n";
        foreach ($errors as $error) {
            if (is_array($error)) {
                echo "Item ".$i." error(s):\n";
                echo "<ul>\n";
                foreach ($error as $itemError) {
                    echo "<li>".$ItemError."</li>\n";
                }
                echo "</ul>\n";
            } else {
                echo "<li>".$error."</li>\n";
            }
            $i++;
        }
        echo "</ul>";

The nested arrays are recognized however the items in the nested arrays don't show up, so I get an empty sub list echoed.

2
  • what's the content of your $errors? try a var_dump or something and see what's happening Commented Jun 4, 2012 at 18:47
  • 2
    It's echo "<li>".$itemError."</li>\n"; not echo "<li>".$ItemError."</li>\n"; Commented Jun 4, 2012 at 18:48

1 Answer 1

4

Check the case of your variable: $itemError/$ItemError

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.