title: Get all values with a certain key value
body: <p>So I've been trying to figure this out for a while now and seem to be stuck. I have a multidimensionalarray and I'm trying to output all values with a certain key. Here is the code:</p>
  
  <pre><code>//My Array:
  $services = array(
                  array(  service_name =&gt; 'facebook', 
                      service_title =&gt; 'Facebook',
                      service_order =&gt; 0, 
                      service_type =&gt; 'Social Networking'
                      ),
                  array(  service_name =&gt; 'twitter', 
                      service_title =&gt; 'Twitter',
                      service_order =&gt; 0,
                      service_type =&gt; 'Social Networking'
                      ),
                  array(  service_name =&gt; 'tumblr', 
                      service_title =&gt; 'MySpace',
                      service_order =&gt; 0, 
                      service_type =&gt; 'Blogging'
                      )
  );
  </code></pre>
  
  <p>The problem is I want to output the values by <code>service_type</code> for example "Social Networking" or "Blogging" I'm able to do this if I use a foreach statement like so:</p>
  
  <pre><code> foreach($services as $service) {
      if ($service['service_type'] == 'Social Networking') {
               echo($service['service_title']);
      }
      if ($service['service_type'] == 'Blogging') {
               echo($service['service_title']);
      }
  }
  </code></pre>
  
  <p>which works fine until I try to add a title in between types like </p>
  
  <pre><code>foreach($services as $service) {
      if ($service['service_type'] == 'Social Networking') {
               echo($service['service_title']);
      }
      echo ('&lt;h3&gt; Blogging&lt;/h3&gt;');
      if ($service['service_type'] == 'Blogging') {
               echo($service['service_title']);
      }
  }
  </code></pre>
  
  <p>I've learned enough to know that is because of the way <code>foreach</code> loops work so I've been trying to do this with something like <code>while($service['service_type'] == 'Social Networking')</code> (which creates a fun infinite loop) and various other ways. </p>
  
  <p>Ideally I want to sort the array by <code>service_type</code> and then display the results without having to run the <code>foreach</code> loop in between headers. </p>
  
  <p>Any help on this would be awesome or even other suggestions on ways to do this. </p>