Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make multidimentional array in php and smarty
    text
    copied!<p>I have this array </p> <pre><code> $a = array("008_@@_1_@@_Interieur_@@_1_@@_Inner-Bags", "008_@@_1_@@_Interieur_@@_2_@@_Color", "008_@@_1_@@_Interieur_@@_3_@@_Material");` </code></pre> <p>and i use the explode function with <em>@@</em> explode this. and i get the array like this..</p> <pre><code>[0] =&gt; 008 [1] =&gt; 1 [2] =&gt; Interieur [3] =&gt; 1 [4] =&gt; Inner-Bags </code></pre> <p>and so on.</p> <p>So i want the type of format array. </p> <pre><code>array('008' =&gt; array( '1' =&gt; array('Interieur' =&gt; array('1' =&gt; 'Inner-Bags', '2' =&gt; 'Color', '3' =&gt; 'Material')))); </code></pre> <p>This is my logic...</p> <pre><code>&lt;?php $a = array("008_@@_1_@@_Interieur_@@_1_@@_Inner-Bags", "008_@@_1_@@_Interieur_@@_2_@@_Color", "008_@@_1_@@_Interieur_@@_3_@@_Material"); $i = 0; echo '&lt;pre&gt;'; $innerD = array(); foreach($a as $key =&gt; $val) { $innerA = array(); $a_exploded = explode("_@@_", $a[$key]); $innerA[$a_exploded[3]] = $a_exploded[4]; } foreach($a as $key =&gt; $val) { //print_r($a[$key]); $innerB = array(); $innerC = array(); $a_exploded = explode("_@@_", $a[$key]); // print_r($innerA); $innerB[$a_exploded[2]] = $innerA; $innerC[$a_exploded[1]] = $innerB; $innerD[$a_exploded[0]] = $innerC; } print_r($innerD); ?&gt; </code></pre> <p>i have use my logic but i din't get it the proper array like this..</p> <pre><code>Array ( [008] =&gt; Array ( [1] =&gt; Array ( [Interieur] =&gt; Array ( [3] =&gt; Material ) ) ) ) </code></pre> <p>and i want to array this format like this..</p> <pre><code>Array ( [008] =&gt; Array ( [1] =&gt; Array ( [Interieur] =&gt; Array ( [1] =&gt; Inner-Bags [2] =&gt; Material [3] =&gt; Color ) ) ) ) </code></pre>
 

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