[ create a new paste ] login | about

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

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

$array = array(
  array( 'type' => 'A', 'month' => 'Jan' ),
  array( 'type' => 'B', 'month' => 'Feb' ),
  array( 'type' => 'A', 'month' => 'Mar' )
);

function callbackFunc( $val ) {
  return $val['type'] == 'A';
}

$result = array_filter( $array, callbackFunc );

print_r( $result );


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Array
(
    [0] => Array
        (
            [type] => A
            [month] => Jan
        )

    [2] => Array
        (
            [type] => A
            [month] => Mar
        )

)


Create a new paste based on this one


Comments: