Home  >  Article  >  php教程  >  array_walk() method callback

array_walk() method callback

WBOY
WBOYOriginal
2016-07-06 13:28:261490browse
Jump to [1] [Full screen preview]
  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