PHP recursive invocation of small tips to explain _php skills

Source: Internet
Author: User

In the actual code of PHP, when we need to implement the multivariate array substitution function, we will encounter PHP recursive call. So what is the specific way to use it? Below we will use a code example to specifically analyze how to implement this functionality.

PHP recursive invocation implements multivariate array substitution function code example:

Copy Code code as follows:

< PHP
$arr = Array ("< small just >", "< Xiao >"), "< small fly >", "< Xiao li >", "< small red >");
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 3 = arrcontentreplact ($arr);
echo "< pre>";
Print_r ($arr 3);
echo "</pre>";
?>

I hope readers will be able to use this PHP recursive call to implement the multivariate array substitution function of the sample code to understand the specific usage.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.