【PHP】array_walk_recursive ― 对数组中的每个成员递归地施用用户函数

WBOY
Release: 2016-06-13 13:19:57
Original
824 people have browsed it

【PHP】array_walk_recursive ― 对数组中的每个成员递归地应用用户函数
PHP里有这么一个函数:
bool array_walk_recursive ( array &$input , callback $funcname [, mixed $userdata ] )
对数组中的每个成员递归地应用用户函数,可以用来处理多维数组内数据,需要批处理数组内数据的时候使用这个函数非常方便。

function gb2312_to_utf8(&$value, $key) { 
    $value = iconv('gb2312', 'utf-8', $value);
}
array_walk_recursive($array, 'gb2312_to_utf8');
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!