Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Warning: Array to string conversion

i stuck at a simple Problem i guess.. I try to get all the data from the strings into one Element (like a ul).

Here at my example: i have tried this:

<pre>

<?php
var_dump ($_POST);

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

?>

</pre>

And this is what i get from the var_dump:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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"
  }
} 

What i want is that each string is going to a ul

I think its very easy but i can´t find a solution especially to my problem..

>Solution :

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

foreach ($_POST as $ul) {
    foreach ($ul as $key => $user) {
        echo $user;
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading