php method to replace characters in an array: first create a PHP sample file; then use the header() method to set the encoding format of the page to utf-8; finally use the str_replace function to replace the specified characters.
#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.
Create a new php file named test.php to explain how to replace the specified characters of each element of the array in php.
In the test.php file, use the header() method to set the encoding format of the page to utf-8.
In the test.php file, create a function findstr. Within the function, use the str_replace function to replace the specified characters.
In the test.php file, create an array with three string elements for testing.
In the test.php file, use the array_map function and the findstr method to replace the bb characters of each element of the array with aa. Finally, use print_r to output the replaced characters. array.
Open the test.php file in the browser to view the results.
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to replace characters in an array in php. For more information, please follow other related articles on the PHP Chinese website!