3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $text = str_repeat( 'm', 2000 ); $long_from_a = str_repeat( 'a', 1 ); $long_from_x = str_repeat( 'x', 1500 ); $replacements = array( $long_from_a => 'b', $long_from_x => 'y' ); $start = microtime( true ); $result_1 = strtr( $text, $replacements ); echo "strtr: " . number_format( microtime( true ) - $start, 4 ) . "\n"; $start = microtime( true ); $result_2 = str_replace( array_keys( $replacements ), array_values( $replacements ), $text ); echo "str_replace: " . number_format( microtime( true ) - $start, 4 ) . "\n"; echo $result_1 === $result_2 ? "results match!\n": "no match!\n";
Output for 5.4.24 - 5.4.25, 5.4.27, 5.4.29 - 5.4.30, 5.4.34 - 5.4.35, 5.5.33 - 5.5.34, 5.6.8, 7.0.0 - 7.2.0
strtr: 0.0000 str_replace: 0.0000 results match!
Output for 5.4.12 - 5.4.23, 5.4.26, 5.4.28, 5.4.31 - 5.4.32, 5.4.36 - 5.5.32, 5.5.35, 5.6.9 - 5.6.28
strtr: 0.0001 str_replace: 0.0000 results match!
Output for 5.4.11
strtr: 1.3722 str_replace: 0.0000 results match!
Output for 5.4.10
strtr: 1.3712 str_replace: 0.0000 results match!
Output for 5.4.9
strtr: 1.3786 str_replace: 0.0000 results match!
Output for 5.4.8
strtr: 1.3447 str_replace: 0.0000 results match!
Output for 5.4.7
strtr: 1.3507 str_replace: 0.0000 results match!
Output for 5.4.6
strtr: 1.3470 str_replace: 0.0000 results match!
Output for 5.4.5
strtr: 1.3597 str_replace: 0.0000 results match!
Output for 5.4.4
strtr: 1.3839 str_replace: 0.0000 results match!
Output for 5.4.3
strtr: 1.3398 str_replace: 0.0000 results match!
Output for 5.4.2
strtr: 1.3517 str_replace: 0.0000 results match!
Output for 5.4.1
strtr: 1.3346 str_replace: 0.0000 results match!
Output for 5.4.0
strtr: 1.3570 str_replace: 0.0000 results match!
Output for 5.3.29
strtr: 0.7935 str_replace: 0.0000 results match!
Output for 5.3.28
strtr: 0.8706 str_replace: 0.0000 results match!
Output for 5.3.27
strtr: 1.4690 str_replace: 0.0000 results match!
Output for 5.3.26
strtr: 1.4763 str_replace: 0.0000 results match!
Output for 5.3.25
strtr: 1.5420 str_replace: 0.0000 results match!
Output for 5.3.24
strtr: 1.4714 str_replace: 0.0000 results match!
Output for 5.3.23
strtr: 1.4904 str_replace: 0.0000 results match!
Output for 5.3.22
strtr: 1.4461 str_replace: 0.0000 results match!
Output for 5.3.21
strtr: 1.4521 str_replace: 0.0000 results match!
Output for 5.3.20
strtr: 1.4403 str_replace: 0.0000 results match!
Output for 5.3.19
strtr: 1.4716 str_replace: 0.0000 results match!
Output for 5.3.18
strtr: 1.4324 str_replace: 0.0000 results match!
Output for 5.3.17
strtr: 1.4944 str_replace: 0.0000 results match!
Output for 5.3.16
strtr: 1.5729 str_replace: 0.0000 results match!
Output for 5.3.15
strtr: 1.4482 str_replace: 0.0000 results match!
Output for 5.3.14
strtr: 1.4489 str_replace: 0.0000 results match!
Output for 5.3.13
strtr: 1.4626 str_replace: 0.0000 results match!
Output for 5.3.12
strtr: 1.4636 str_replace: 0.0000 results match!
Output for 5.3.11
strtr: 1.4570 str_replace: 0.0000 results match!
Output for 5.3.10
strtr: 1.4596 str_replace: 0.0000 results match!
Output for 5.3.9
strtr: 1.5101 str_replace: 0.0000 results match!
Output for 5.3.2, 5.3.8
strtr: 1.4656 str_replace: 0.0000 results match!
Output for 5.3.7
strtr: 1.4452 str_replace: 0.0000 results match!
Output for 5.3.6
strtr: 1.4586 str_replace: 0.0000 results match!
Output for 5.3.5
strtr: 1.4581 str_replace: 0.0000 results match!
Output for 5.3.4
strtr: 1.4408 str_replace: 0.0000 results match!
Output for 5.3.3
strtr: 1.4743 str_replace: 0.0000 results match!
Output for 5.3.1
strtr: 1.4958 str_replace: 0.0001 results match!
Output for 5.3.0
strtr: 1.4782 str_replace: 0.0000 results match!
Output for 5.1.4, 5.2.17
strtr: 1.4838 str_replace: 0.0000 results match!
Output for 5.2.16
strtr: 1.4400 str_replace: 0.0000 results match!
Output for 5.2.15
strtr: 1.4885 str_replace: 0.0000 results match!
Output for 5.2.14
strtr: 1.4653 str_replace: 0.0000 results match!
Output for 5.2.13
strtr: 1.4498 str_replace: 0.0000 results match!
Output for 5.2.12
strtr: 1.4665 str_replace: 0.0000 results match!
Output for 5.2.11
strtr: 1.4676 str_replace: 0.0000 results match!
Output for 5.2.10
strtr: 1.5011 str_replace: 0.0000 results match!
Output for 5.2.9
strtr: 1.4549 str_replace: 0.0000 results match!
Output for 5.2.8
strtr: 1.4861 str_replace: 0.0000 results match!
Output for 5.2.7
strtr: 1.4663 str_replace: 0.0000 results match!
Output for 5.2.6
strtr: 1.4480 str_replace: 0.0000 results match!
Output for 5.2.5
strtr: 1.5767 str_replace: 0.0000 results match!
Output for 5.2.4
strtr: 1.4465 str_replace: 0.0000 results match!
Output for 5.2.3
strtr: 1.4711 str_replace: 0.0000 results match!
Output for 5.2.2
strtr: 1.4435 str_replace: 0.0000 results match!
Output for 5.2.1
strtr: 1.4407 str_replace: 0.0000 results match!
Output for 5.2.0
strtr: 1.4477 str_replace: 0.0000 results match!
Output for 5.1.6
strtr: 1.4741 str_replace: 0.0000 results match!
Output for 5.1.5
strtr: 1.4539 str_replace: 0.0000 results match!
Output for 5.1.3
strtr: 1.4589 str_replace: 0.0000 results match!
Output for 5.1.2
strtr: 0.9320 str_replace: 0.0000 results match!
Output for 5.1.1
strtr: 0.9177 str_replace: 0.0000 results match!
Output for 5.1.0
strtr: 0.8984 str_replace: 0.0000 results match!
Output for 5.0.5
strtr: 0.9210 str_replace: 0.0000 results match!
Output for 5.0.4
strtr: 0.9217 str_replace: 0.0000 results match!
Output for 5.0.3
strtr: 0.8924 str_replace: 0.0000 results match!
Output for 5.0.2
strtr: 0.8644 str_replace: 0.0000 results match!
Output for 5.0.1
strtr: 0.8613 str_replace: 0.0000 results match!
Output for 5.0.0
strtr: 0.9000 str_replace: 0.0000 results match!
Output for 4.4.9
strtr: 0.0586 str_replace: 0.0000 results match!
Output for 4.4.8
strtr: 0.0660 str_replace: 0.0000 results match!
Output for 4.4.7
strtr: 0.0746 str_replace: 0.0000 results match!
Output for 4.4.6
strtr: 0.0443 str_replace: 0.0000 results match!
Output for 4.4.5
strtr: 0.0079 str_replace: 0.0000 results match!
Output for 4.4.4
strtr: 0.0795 str_replace: 0.0000 results match!
Output for 4.4.3
strtr: 0.0352 str_replace: 0.0000 results match!
Output for 4.4.2
strtr: -0.9306 str_replace: 0.0000 results match!
Output for 4.4.1
strtr: 0.0508 str_replace: 0.0000 results match!
Output for 4.4.0
strtr: 0.0680 str_replace: 0.0000 results match!
Output for 4.3.11
strtr: 0.0286 str_replace: 0.0000 results match!
Output for 4.3.10
strtr: 0.0054 str_replace: 0.0000 results match!
Output for 4.3.9
strtr: 0.0570 str_replace: 0.0000 results match!
Output for 4.3.8
strtr: 0.0619 str_replace: 0.0000 results match!
Output for 4.3.7
strtr: 0.0621 str_replace: 0.0000 results match!
Output for 4.3.6
strtr: 0.0707 str_replace: 0.0000 results match!
Output for 4.3.5
strtr: 0.0367 str_replace: 0.0000 results match!
Output for 4.3.4
strtr: 0.0254 str_replace: 0.0000 results match!
Output for 4.3.3
strtr: 0.0155 str_replace: 0.0000 results match!
Output for 4.3.2
strtr: 0.0495 str_replace: 0.0000 results match!
Output for 4.3.1
strtr: 0.0333 str_replace: 0.0000 results match!
Output for 4.3.0
strtr: -0.9289 str_replace: 0.0000 results match!