title: Parsing a Nested Array (PHP)
body: <p>I am trying to find an efficient way to do the following :</p>
  
  <p>1) Parse an array.
  2) If the element is a single value, store it/echo it.
  3) If the element is an array, Parse it and store/echo all of its elements.</p>
  
  <p>An example would be :</p>
  
  <p>$array = array(15,25,'Dog',[11,'Cat','Cookie15'],22)</p>
  
  <p>This would be echo'd as :</p>
  
  <p>15
  25
  Dog
  11
  Cat
  Cookie15
  22</p>
  
  <p>Note : The maximum number of Nested layers of Arrays = 2 (The max is an Array within an Array, not deeper than that).</p>
  
  <p>The code I have made so far is :</p>
  
  <pre><code>foreach($_POST as $key=&gt;$value){  
        if(is_array($value))
        {
        &lt;Not sure how to handle this condition! Need to parse the array and echo individual elements&gt;
        }
        else
        {
         echo "Input name : $key Value : $value  ";
        }
  }
  </code></pre>
  
  <p>Edit: The following is my dump for the array. The nested elements show blank for some odd reason!</p>
  
  <pre><code>string '15' (length=2)
  
  string '25' (length=2)
  
  string 'Dog' (length=3)
  
  array (size=3)
    0 =&gt; string '' (length=0)
    1 =&gt; string '' (length=0)
    2 =&gt; string '' (length=0)
  
  string '22' (length=2)
  </code></pre>
  
  <p>The relevant code is :</p>
  
  <pre><code>foreach($_POST as $input) {
   var_dump($input);
  }
  </code></pre>