What is the difference between the efficiency of strtr, str_replace and preg_replace functions
This article is about the difference between the efficiency of strtr, str_replace and preg_replace functions. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Having analyzed the source code of strtr before, compare the efficiency of strtr, str_replace and preg_replace:
The code is as follows:
$str =
'1111111100000000000000000000000001110000010000010010000010010000010100000010
'
$str = str_repeat ($str, 1)
$pattern1 = array ('12345) = >', '67891 = >')
$pattern2 = array ('averse = >', '1234567890 = >')
$pattern3 ='/ 12345 | 67891 Zero'
$pattern4 ='/ a | 1234567890 Universe'
$pattern5 = array ('12345,' 67891')
$pattern6 = array ('asides,' 1234567890')
$t = microtime (true)
For ($iTun0; $I