0

I'm stuck on a simple problem. I'm trying to get all the data from the strings into one Element (like a ul).

Here is what I have tried:

<pre>

<?php
var_dump ($_POST);

foreach ($_POST as $user) {
enter code hereecho $user;
}

?>

</pre>

And this is what i get from the var_dump:

array(1) {
  ["firstUl"]=>
  array(6) {
    [0]=>
    string(5) "Test1"
    [1]=>
    string(5) "Test2"
    [2]=>
    string(5) "Test3"
    [3]=>
    string(5) "Test4"
    [4]=>
    string(5) "Test5"
    [5]=>
    string(5) "Test6"
  }
} 

I want to put each string inside a ul. I cant find a solution.

0

1 Answer 1

3

You should define the index for your foreach, for example :

foreach ($_POST as $ul) {
    foreach ($ul as $key => $user) {
        echo $user;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

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.