title: PHP: Separate Array based on a value
body: <p>I have got the following array:</p>
  
  <pre><code>$raw = [
      [
          'prop1' =&gt; 'somevalue',
          'prop2' =&gt; 'anothervalue',
          'path' =&gt; 'used'
      ],
      [
          'prop1' =&gt; 'somevalue',
          'prop2' =&gt; 'anothervalue',
          'path' =&gt; 'used'
      ],
      [
          'prop1' =&gt; 'somevalue',
          'prop2' =&gt; 'anothervalue',
          'path' =&gt; 'used'
      ],
      [
          'prop1' =&gt; 'somevalue',
          'prop2' =&gt; 'anothervalue',
          'path' =&gt; 'used'
      ],
      [
          'prop1' =&gt; 'somevalue',
          'prop2' =&gt; 'anothervalue',
          'path' =&gt; 'used'
      ],
      [
          'prop1' =&gt; 'somevalue',
          'prop2' =&gt; 'anothervalue',
          'path' =&gt; 'new'
      ],
      [
          'prop1' =&gt; 'somevalue',
          'prop2' =&gt; 'anothervalue',
          'path' =&gt; 'new'
      ],
      [
          'prop1' =&gt; 'somevalue',
          'prop2' =&gt; 'anothervalue',
          'path' =&gt; 'new'
      ],
  ];
  </code></pre>
  
  <p>I need to filter through this array, preferably using <code>filter_array</code> to keep the code cleaner, I need to filter based on the <code>path</code> property. So I would end up with:</p>
  
  <pre><code>$filtered = [
      'used' =&gt; [
          [
              'prop1' =&gt; 'somevalue',
              'prop2' =&gt; 'anothervalue',
              'path' =&gt; 'used'
          ],
          [
              'prop1' =&gt; 'somevalue',
              'prop2' =&gt; 'anothervalue',
              'path' =&gt; 'used'
          ],
          [
              'prop1' =&gt; 'somevalue',
              'prop2' =&gt; 'anothervalue',
              'path' =&gt; 'used'
          ],
          [
              'prop1' =&gt; 'somevalue',
              'prop2' =&gt; 'anothervalue',
              'path' =&gt; 'used'
          ],
          [
              'prop1' =&gt; 'somevalue',
              'prop2' =&gt; 'anothervalue',
              'path' =&gt; 'used'
          ]
      ],
      'new' =&gt; [
          [
              'prop1' =&gt; 'somevalue',
              'prop2' =&gt; 'anothervalue',
              'path' =&gt; 'new'
          ],
          [
              'prop1' =&gt; 'somevalue',
              'prop2' =&gt; 'anothervalue',
              'path' =&gt; 'new'
          ],
          [
              'prop1' =&gt; 'somevalue',
              'prop2' =&gt; 'anothervalue',
              'path' =&gt; 'new'
          ]
      ]
  ];
  </code></pre>