[ create a new paste ] login | about

Link: http://codepad.org/WZXIvQ58    [ raw code | output | fork ]

PHP, pasted on Apr 10:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php 

$apps = array(
  Array( "ID" => 0, "CategoryID" => 12 ),
  Array( "ID" => 9, "CategoryID" => 12 ),
  Array( "ID" => 4, "CategoryID" => 16 ),
  Array( "ID" => 3, "CategoryID" => 11 )
);

$catArray = array();

foreach ( $apps as $app ) {
    $catArray[ $app[CategoryID] ][] = $app;
}

print_r( $catArray );

?>


Output:
Array
(
    [12] => Array
        (
            [0] => Array
                (
                    [ID] => 0
                    [CategoryID] => 12
                )

            [1] => Array
                (
                    [ID] => 9
                    [CategoryID] => 12
                )

        )

    [16] => Array
        (
            [0] => Array
                (
                    [ID] => 4
                    [CategoryID] => 16
                )

        )

    [11] => Array
        (
            [0] => Array
                (
                    [ID] => 3
                    [CategoryID] => 11
                )

        )

)


Create a new paste based on this one


Comments: