Blogger Information
Blog 18
fans 0
comment 0
visits 24336
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
array_walk()函数
耀的博客
Original
1500 people have browsed it

bool array_walk(array$array,callback$callback[,mixed $userdata=null])

函数说明:

功能:传入一个回调函数,将数组原来的进行组操作,并且发生变化。

返回值:bool值,提示成功或者失败。

参数说明:

第一个参数就是要操作的数组;

第二个参数是callback,代表着可以传入函数或者匿名函数。

例子:

<?php

$shuaige = array("a" => "wuyanzhu", "b" => "huangxiaoming", "c" => "ninzetao");


function test_print($item2, $key)

{

   echo $key ." ---". strtoupper($item2) . "<br />\n";//strtoupper();字符串转换大写;

}


echo '<pre>';

var_dump($shuaige);

echo '</pre>';



array_walk($shuaige, 'test_print');//array_walk();单一数组回调函数---对数组中的每个成员应用用户函数


echo '用自定义函数test_print执行后的效果:';


echo '<pre>';

var_dump($shuaige);

echo '</pre>';


?>


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post