php自定义函数递归替换数组中的内容
时间:2021-07-01 10:21:17
帮助过:5人阅读
/** - desc:递归替换数组内容
- link:bbs.it-home.org
- date:2013/2/22
- */
- function arrContentReplact($array)
- {
- if(is_array($array))
- {
- foreach($array as $k => $v)
- {
- $array[$k] = arrContentReplact($array[$k]);
- }
- }else
- {
- $array = str_replace(
- array('<', '>'),
- array('{', '}'),
- $array
- );
- }
- return $array;
- }
//调用示例 - $arr = array(array("< jbxue1>","< jb2xue>",array("",array(""))),"< jb33xue>","< jbxue44>","< 44jbxue>");
- $arr3 = arrContentReplact($arr);
- echo "
"; - print_r($arr3);
- echo "";
- ?>
|