3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //Source: https://bugs.php.net/bug.php?id=63893 $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.6.3, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
strtr: 0.0000 str_replace: 0.0000 results match!
Output for 5.4.12 - 5.6.2, 5.6.4 - 5.6.28
strtr: 0.0001 str_replace: 0.0000 results match!
Output for 5.4.11
strtr: 0.8446 str_replace: 0.0000 results match!
Output for 5.4.10
strtr: 0.8448 str_replace: 0.0000 results match!
Output for 5.4.9
strtr: 0.8128 str_replace: 0.0000 results match!
Output for 5.4.8
strtr: 0.8525 str_replace: 0.0000 results match!
Output for 5.4.7
strtr: 0.7592 str_replace: 0.0000 results match!
Output for 5.4.6
strtr: 0.8119 str_replace: 0.0000 results match!
Output for 5.4.5
strtr: 0.7156 str_replace: 0.0000 results match!
Output for 5.4.4
strtr: 0.7772 str_replace: 0.0000 results match!
Output for 5.4.3
strtr: 0.8310 str_replace: 0.0000 results match!
Output for 5.4.2
strtr: 0.7949 str_replace: 0.0000 results match!
Output for 5.4.1
strtr: 0.8214 str_replace: 0.0000 results match!
Output for 5.4.0
strtr: 0.6902 str_replace: 0.0000 results match!
Output for 5.3.29
strtr: 0.8184 str_replace: 0.0000 results match!
Output for 5.3.28
strtr: 0.8871 str_replace: 0.0000 results match!
Output for 5.3.27
strtr: 0.9140 str_replace: 0.0000 results match!
Output for 5.3.26
strtr: 0.8855 str_replace: 0.0000 results match!
Output for 5.3.25
strtr: 0.8885 str_replace: 0.0000 results match!
Output for 5.3.24
strtr: 0.8924 str_replace: 0.0000 results match!
Output for 5.3.23
strtr: 0.8865 str_replace: 0.0000 results match!
Output for 5.3.22
strtr: 0.8834 str_replace: 0.0000 results match!
Output for 5.3.21
strtr: 0.8724 str_replace: 0.0000 results match!
Output for 5.3.20
strtr: 0.8556 str_replace: 0.0000 results match!
Output for 5.3.19
strtr: 0.9200 str_replace: 0.0000 results match!
Output for 5.3.18
strtr: 0.8975 str_replace: 0.0000 results match!
Output for 5.3.2, 5.3.17
strtr: 0.9250 str_replace: 0.0000 results match!
Output for 5.3.16
strtr: 0.8659 str_replace: 0.0000 results match!
Output for 5.3.15
strtr: 0.8319 str_replace: 0.0000 results match!
Output for 5.3.14
strtr: 0.7326 str_replace: 0.0000 results match!
Output for 5.3.13
strtr: 0.7782 str_replace: 0.0000 results match!
Output for 5.3.12
strtr: 0.7930 str_replace: 0.0000 results match!
Output for 5.3.11
strtr: 0.9192 str_replace: 0.0000 results match!
Output for 5.1.4, 5.3.10
strtr: 0.8968 str_replace: 0.0000 results match!
Output for 5.3.9
strtr: 0.8666 str_replace: 0.0000 results match!
Output for 5.3.8
strtr: 0.8664 str_replace: 0.0000 results match!
Output for 5.3.7
strtr: 0.8663 str_replace: 0.0000 results match!
Output for 5.3.6
strtr: 0.7321 str_replace: 0.0000 results match!
Output for 5.3.5
strtr: 0.8931 str_replace: 0.0000 results match!
Output for 5.3.4
strtr: 0.9242 str_replace: 0.0000 results match!
Output for 5.3.3
strtr: 0.9049 str_replace: 0.0000 results match!
Output for 5.3.1
strtr: 0.9152 str_replace: 0.0000 results match!
Output for 5.3.0
strtr: 0.9115 str_replace: 0.0000 results match!
Output for 5.2.17
strtr: 0.9056 str_replace: 0.0000 results match!
Output for 5.2.16
strtr: 0.8810 str_replace: 0.0000 results match!
Output for 5.2.15
strtr: 0.8890 str_replace: 0.0000 results match!
Output for 5.2.14
strtr: 0.9276 str_replace: 0.0000 results match!
Output for 5.2.13
strtr: 0.9103 str_replace: 0.0000 results match!
Output for 5.2.12
strtr: 0.7598 str_replace: 0.0000 results match!
Output for 5.2.11
strtr: 0.8851 str_replace: 0.0000 results match!
Output for 5.2.10
strtr: 0.9074 str_replace: 0.0000 results match!
Output for 5.2.9
strtr: 0.8892 str_replace: 0.0000 results match!
Output for 5.2.8
strtr: 0.8772 str_replace: 0.0000 results match!
Output for 5.2.7
strtr: 0.8920 str_replace: 0.0000 results match!
Output for 5.2.6
strtr: 0.9150 str_replace: 0.0000 results match!
Output for 5.2.5
strtr: 0.8881 str_replace: 0.0000 results match!
Output for 5.2.4
strtr: 0.8854 str_replace: 0.0000 results match!
Output for 5.2.3
strtr: 0.8807 str_replace: 0.0000 results match!
Output for 5.2.2
strtr: 0.8961 str_replace: 0.0000 results match!
Output for 5.2.1
strtr: 0.9319 str_replace: 0.0000 results match!
Output for 5.2.0
strtr: 0.8752 str_replace: 0.0000 results match!
Output for 5.1.6
strtr: 0.7862 str_replace: 0.0000 results match!
Output for 5.1.5
strtr: 0.9386 str_replace: 0.0000 results match!
Output for 5.1.3
strtr: 0.8861 str_replace: 0.0000 results match!
Output for 5.1.2
strtr: 0.8884 str_replace: 0.0000 results match!
Output for 5.1.1
strtr: 0.8070 str_replace: 0.0000 results match!
Output for 5.1.0
strtr: 0.7937 str_replace: 0.0000 results match!
Output for 5.0.5
strtr: 0.9277 str_replace: 0.0000 results match!
Output for 5.0.4
strtr: 0.7664 str_replace: 0.0000 results match!
Output for 5.0.3
strtr: 0.8719 str_replace: 0.0000 results match!
Output for 5.0.2
strtr: 0.7495 str_replace: 0.0000 results match!
Output for 5.0.1
strtr: 0.8059 str_replace: 0.0000 results match!
Output for 5.0.0
strtr: 0.7457 str_replace: 0.0000 results match!
Output for 4.4.9
strtr: 0.0403 str_replace: 0.0000 results match!
Output for 4.4.8
strtr: 0.0397 str_replace: 0.0000 results match!
Output for 4.4.7
strtr: 0.9461 str_replace: 0.0000 results match!
Output for 4.4.6
strtr: 0.0173 str_replace: 0.0000 results match!
Output for 4.4.5
strtr: 0.0537 str_replace: 0.0000 results match!
Output for 4.4.4
strtr: 0.0229 str_replace: 0.0000 results match!
Output for 4.4.3
strtr: 0.0191 str_replace: 0.0000 results match!
Output for 4.4.2
strtr: 0.0939 str_replace: 0.0000 results match!
Output for 4.4.1
strtr: 0.0435 str_replace: 0.0000 results match!
Output for 4.4.0
strtr: 0.0062 str_replace: 0.0000 results match!
Output for 4.3.11
strtr: 0.8512 str_replace: 0.0000 results match!
Output for 4.3.10
strtr: 0.9075 str_replace: 0.0000 results match!
Output for 4.3.9
strtr: 0.8579 str_replace: 0.0000 results match!
Output for 4.3.8
strtr: 0.9809 str_replace: 0.0000 results match!
Output for 4.3.7
strtr: 0.0440 str_replace: 0.0000 results match!
Output for 4.3.6
strtr: 0.9157 str_replace: 0.0000 results match!
Output for 4.3.5
strtr: 0.9531 str_replace: 0.0000 results match!
Output for 4.3.4
strtr: 0.0273 str_replace: 0.0000 results match!
Output for 4.3.3
strtr: 0.0721 str_replace: 0.0000 results match!
Output for 4.3.2
strtr: 0.0548 str_replace: 0.0000 results match!
Output for 4.3.1
strtr: 0.0589 str_replace: 0.0000 results match!
Output for 4.3.0
strtr: 0.0203 str_replace: 0.0000 results match!