title: create multidimensional array using a foreach loop
body: <p>I am trying to create a multidimensional array in PHP using a foreach loop.  Here is the code thus far:</p>
  
  <pre><code>$levels = array('low', 'medium', 'high');
  $attributes = array('fat', 'quantity', 'ratio', 'label');
  
  foreach ($levels as $key =&gt; $level):
         foreach ($attributes as $k =&gt;$attribute):
               $variables[] = $attribute . '_' . $level;
         endforeach;
  endforeach;
  
  echo '&lt;pre&gt;' . print_r($levels,1) . '&lt;/pre&gt;';   
  echo '&lt;pre&gt;' . print_r($variables,1) . '&lt;/pre&gt;';    
  </code></pre>
  
  <p>The output from this code is a single dimension array; however, that is not the intent.  The desired array should look like this:</p>
  
  <p><img src="https://i.stack.imgur.com/h1LXB.png" alt="OutputGoal"></p>
  
  <p>How should the code be modified to achieve the goal?</p>