Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying an array inside an array?
    text
    copied!<p>I have an array inside an array and I'd like to simply print out the contents of it... the problem is what I'm trying doesn't work... ie</p> <pre><code> foreach($retval as $k=&gt;$v){ if (is_array($v)){ foreach($v as $l=&gt;$w){ echo $l . ' = ' . $w . '&lt;br /&gt;'; } } else { echo $k . ' = ' . $v . '&lt;br /&gt;'; } </code></pre> <p>Doing that however I end up with:</p> <p>id = 2</p> <p>name = Speakers</p> <p>form_field = hidden</p> <p>display_order = 0</p> <p>groups = Array</p> <p>So I'm not getting a foreach in that inside array.. what am I doing wrong? It seems actually that my code believes everything return is an array when I'm pretty sure that only 'groups' is an array.</p> <hr> <p>the structure of the array looks like so:</p> <pre><code>array ( 0 =&gt; array ( 'id' =&gt; 2, 'name' =&gt; 'Speakers', 'form_field' =&gt; 'hidden', 'display_order' =&gt; '0', 'groups' =&gt; array ( 0 =&gt; array ( 'bit' =&gt; '1', 'name' =&gt; 'don', 'display_order' =&gt; '4', 'subscribers' =&gt; 8, ), 1 =&gt; array ( 'bit' =&gt; '2', 'name' =&gt; 'tyler', 'display_order' =&gt; '5', 'subscribers' =&gt; 0, ), 2 =&gt; array ( 'bit' =&gt; '4', 'name' =&gt; 'stephen', 'display_order' =&gt; '6', 'subscribers' =&gt; 0, ), 3 =&gt; array ( 'bit' =&gt; '8', 'name' =&gt; 'daniel', 'display_order' =&gt; '7', 'subscribers' =&gt; 0, ), 4 =&gt; array ( 'bit' =&gt; '16', 'name' =&gt; 'william', 'display_order' =&gt; '8', 'subscribers' =&gt; 0, ), 5 =&gt; array ( 'bit' =&gt; '32', 'name' =&gt; 'bobbys', 'display_order' =&gt; '9', 'subscribers' =&gt; 0, ), ), ), ) </code></pre> <p>Long story short, I'm actually just trying to search this whole thing for say the name 'bobby' and get a simple true or false on whether that value exists anywhere in there.</p>
 

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