Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay multidimensional array elements in smarty
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/7609929/display-array-elements-in-smarty">Display array elements in smarty</a> </p> </blockquote> <p>I have merged two mysql results :</p> <pre><code>while($rs_1 = mysql_fetch_array($r1)) { $arr1[] = $rs_1; } while($rs_2 = mysql_fetch_array($r2)) { $arr2[] = $rs_2; } $resN = array_merge($arr1,$arr2); </code></pre> <p><code>var_dump($resN)</code> shows the following result :</p> <pre><code>array(5) { [0]=&gt; array(4) { [0]=&gt; string(6) "Petric" ["bz_pro_first_name"]=&gt; string(6) "Petric" [1]=&gt; string(8) "Naughton" ["bz_pro_last_name"]=&gt; string(8) "Naughton" } [1]=&gt; array(4) { [0]=&gt; string(6) "Nitish" ["bz_pro_first_name"]=&gt; string(6) "Nitish" [1]=&gt; string(12) "Dolakasharia" ["bz_pro_last_name"]=&gt; string(12) "Dolakasharia" } [2]=&gt; array(4) { [0]=&gt; string(6) "Martin" ["bz_pro_first_name"]=&gt; string(6) "Martin" [1]=&gt; string(3) "Rom" ["bz_pro_last_name"]=&gt; string(3) "Rom" } [3]=&gt; array(4) { [0]=&gt; string(5) "Steve" ["bz_pro_first_name"]=&gt; string(5) "Steve" [1]=&gt; string(5) "Wough" ["bz_pro_last_name"]=&gt; string(5) "Wough" } [4]=&gt; array(4) { [0]=&gt; string(3) "Liz" ["bz_pro_first_name"]=&gt; string(3) "Liz" [1]=&gt; string(6) "Hurley" ["bz_pro_last_name"]=&gt; string(6) "Hurley" } } </code></pre> <p>I am supposed to display them in smarty so :</p> <pre><code>assign_values('rand_pro',$resN); </code></pre> <p>Now I tried to display in smarty like this :</p> <pre><code>{foreach name=outer item=pro from=$rand_pro} {foreach key=key item=item from=$pro} {$key}: {$item}&lt;br /&gt; {/foreach} {/foreach} </code></pre> <p>It displays the results but serially. I need to extract the values in some positions . So how can I extract the values eg first name, last name etc ?</p>
    singulars
    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.
    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