[ create a new paste ] login | about

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

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

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

foreach( $array as $key => &$value ){
	if ( $value['type'] != 'A' )
		unset( $array[ $key ] );
}

print_r( $array );


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: