Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP: foreach in multidimensional arrays
    primarykey
    data
    text
    <p>I have a dynamic form for creating chapters and sub-chapters that creates an array:</p> <p>var_dump($_POST);</p> <pre><code>array{["textfield"] =&gt; array { [0] =&gt; "title one" [1] =&gt; "title two" [2] =&gt; "title three" [4] =&gt; "title four" } ["textarea"] =&gt; array { [0] =&gt; "title text" [1] =&gt; "title summary" [2] =&gt; "title description" [4] =&gt; "title details" } ["hidden"] =&gt; array { [0] =&gt; "1" [1] =&gt; "2" [2] =&gt; "3" [4] =&gt; "1" } } </code></pre> <p>I'm very weak with arrays. Ive read several articles on multidimentional arrays and sorting but havent had any luck or seen any examples closely enough resembling mine for me to understand how I need to adjust this. </p> <p>I would like to for each:</p> <pre><code>&lt;div class="row&lt;? echo $hidden ?&gt;"&gt; &lt;h2&gt;&lt;? echo $textfield ?&gt;&lt;/h2&gt; &lt;h3&gt;&lt;? echo $textarea ?&gt;&lt;/h3&gt; &lt;/div&gt; </code></pre> <p>that matches key 0 (or corresponding key number) and value through several arrays. Similar to:</p> <pre><code>&lt;div class="row&lt;? echo $_POST['hidden'][0] ?&gt;"&gt; &lt;h2&gt;&lt;? echo $_POST['textfield'][0] ?&gt;&lt;/h2&gt; &lt;h3&gt;&lt;? echo $_POST['textarea'][0] ?&gt;&lt;/h3&gt; &lt;/div&gt; &lt;div class="row&lt;? echo $_POST['hidden'][1] ?&gt;"&gt; &lt;h2&gt;&lt;? echo $_POST['textfield'][1] ?&gt;&lt;/h2&gt; &lt;h3&gt;&lt;? echo $_POST['textarea'][1] ?&gt;&lt;/h3&gt; &lt;/div&gt; &lt;div class="row&lt;? echo $_POST['hidden'][2] ?&gt;"&gt; &lt;h2&gt;&lt;? echo $_POST['textfield'][2] ?&gt;&lt;/h2&gt; &lt;h3&gt;&lt;? echo $_POST['textarea'][2] ?&gt;&lt;/h3&gt; &lt;/div&gt; &lt;div class="row&lt;? echo $_POST['hidden'][3] ?&gt;"&gt; &lt;h2&gt;&lt;? echo $_POST['textfield'][3] ?&gt;&lt;/h2&gt; &lt;h3&gt;&lt;? echo $_POST['textarea'][3] ?&gt;&lt;/h3&gt; &lt;/div&gt; </code></pre> <p>This form could dynamically be created hundreds deep and I've only been able to print the entire array or all $values for each $key. Ive not had any success matching through various arrays.</p> <p>I hope you follow. If you have any suggestions, I'd be very grateful.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload