Reputation: 31
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.
Upvotes: 0
Views: 10166
Reputation: 502
You should define the index for your foreach, for example :
foreach ($_POST as $ul) {
foreach ($ul as $key => $user) {
echo $user;
}
}
Upvotes: 3