1 개요[ | ]
- Underscore.php filter()
- 함수 조건에 맞추는 요소를 반환하는 함수
2 예시[ | ]
PHP
Copy
include '/usr/share/php/vendor/Underscore.php/underscore.php';
$rows = array(
array('id'=>1, 'name'=>'한놈', 'depratment_id'=>1, 'birth_date'=>'1999-01-01'),
array('id'=>2, 'name'=>'두시기', 'depratment_id'=>2, 'birth_date'=>'2000-01-01'),
array('id'=>3, 'name'=>'석삼', 'depratment_id'=>2, 'birth_date'=>'1999-01-01'),
array('id'=>4, 'name'=>'너구리', 'depratment_id'=>2, 'birth_date'=>'2000-01-01'),
);
$selected = __::filter($rows, function($r){ return $r['birth_date']=='1999-01-01'; });
print_r($selected);
# Array
# (
# [0] => Array
# (
# [id] => 1
# [name] => 한놈
# [depratment_id] => 1
# [birth_date] => 1999-01-01
# )
#
# [1] => Array
# (
# [id] => 3
# [name] => 석삼
# [depratment_id] => 2
# [birth_date] => 1999-01-01
# )
# )
3 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.