Home  >  Article  >  php教程  >  array_walk()方法回调

array_walk()方法回调

WBOY
WBOYOriginal
2016-07-06 13:28:261444browse
跳至 [1] [全屏预览]
  1 <?php
  2 $array = array('foo' => 'bar', 'baz' => 'bat');
  3 
  4 array_walk($array, function($val,$key) use(&$array){
  5     if ($val == 'bar') {
  6         unset($array[$key]);
  7     }
  8 });
  9 
 10 var_dump($array);
 11 ?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn