Home  >  Article  >  Backend Development  >  PHP function recursive call example_PHP tutorial

PHP function recursive call example_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 14:54:111107browse


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("< 小刚>","< 小晓>",array("<小强>",array("<浪人>"))),"< 小飞>","< 小李>","< 小红>");
$arr3 = arrContentReplact($arr);
echo "

";<br>print_r($arr3);<br>echo "
";
?> 

作者:k7gxn56

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/364658.htmlTechArticle?php function arrContentReplact($array) { if(is_array($array)) { foreach($array as $k = $v) { $array[$k] = arrContentReplact($array[$k]); } }else { $array = str_replace( array('',...
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