Skip to content

Instantly share code, notes, and snippets.

@dataich
Created December 4, 2009 12:50
Show Gist options
  • Save dataich/249007 to your computer and use it in GitHub Desktop.
Save dataich/249007 to your computer and use it in GitHub Desktop.
<?php
$records = array(
array('name' => '田中 太郎', 'sex' => 1),
array('name' => '田中 花子', 'sex' => 2),
array('name' => '鈴木 太郎', 'sex' => 1),
array('name' => '鈴木 花子', 'sex' => 2)
);
$filter = create_function('$record', 'return $record["sex"] == 1;'); //1
$male_only = array_filter($records, $filter); //2
print_r($male_only);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment