来源:未知 时间:2015-07-13 16:26 作者:xxadmin 阅读:次
[导读] 本次讲解 php里array_work用法,带大家深入了解 php里array_work用法 //thetestarray$array=array(php,arrays,are,cool);//somevariablefortesting:$some_var=NEW;//thefunctionthatgetscalledforeachentryfunctionformat_array_values($it...
|
本次讲解php里array_work用法,带大家深入了解php里array_work用法 // the test array
$array = array(
'php', 'arrays', 'are', 'cool'
);
// some variable for testing:
$some_var = 'NEW';
// the function that get's called for each entry
function format_array_values(&$item, $key, $some_var) {
$item = $some_var . ": $item (KEY: $key)<br/>";
}
// "walk" trough each array item and call the function:
// "format_array_values"
array_walk($array, 'format_array_values', $some_var);
// print the result:
print_r($array);
/*
The output will be:
Array
(
[0] => NEW: php (KEY: 0)<br/>
[1] => NEW: arrays (KEY: 1)<br/>
[2] => NEW: are (KEY: 2)<br/>
[3] => NEW: cool (KEY: 3)<br/>
)
*/ |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com