For PHP beginners, PHP recursive usage may be unfamiliar. Let's talk about how to implement the multi-element array replacement function by using PHP recursive calls today.
For PHP beginners, PHP recursive usage may be unfamiliar. Let's talk about how to implement the multi-element array replacement function by using PHP recursive calls today.
In the actual PHP encoding, PHP recursive calls are encountered when we need to implement the multi-element array replacement function. So what is the specific usage? The following is a code example to illustrate how to implement this function.
Example code of PHP recursive call to implement the multi-element array replacement function:
The Code is as follows:
<? Php
$ Arr = array ("<Xiaogang>", "<Xiao>"), "<Xiao Fei>", "<Xiao LI>", "<Xiao Hong> ");
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;
}
$ Arr3 = arrContentReplact ($ arr );
Echo "<pre> ";
Print_r ($ arr3 );
Echo "</pre> ";
?>
We hope that readers can use the above example code of PHP recursive call to implement the multi-element array replacement function and learn how to use it.