3v4l.org

run code in 300+ PHP versions simultaneously
<?php $filename = 'test/test/foo/bar/baz.php'; $start = microtime(true); for ($i = 0; $i < 1000000; $i++) { in_array(pathinfo( $filename, PATHINFO_EXTENSION ), ['php', 'phtml']); } echo 'in_array: ' . ( microtime(true) - $start ) . "\n"; $start = microtime(true); for ($i = 0; $i < 1000000; $i++) { preg_match('/\.(?:php|phtml)/i', $filename); } echo 'preg: ' . ( microtime(true) - $start );
Output for 7.4.6
in_array: 1.0675389766693 preg: 0.089541912078857
Output for 7.4.5
in_array: 1.1162559986115 preg: 0.10042810440063
Output for 7.4.4
in_array: 1.1819498538971 preg: 0.094058990478516
Output for 7.4.3
in_array: 1.2189049720764 preg: 0.096508026123047
Output for 7.4.2
in_array: 1.0771279335022 preg: 0.092262029647827
Output for 7.4.1
in_array: 1.128937959671 preg: 0.094250917434692
Output for 7.4.0
in_array: 1.0747330188751 preg: 0.095830917358398
Output for 7.3.18
in_array: 1.1200051307678 preg: 0.10434007644653
Output for 7.3.17
in_array: 1.0800549983978 preg: 0.11225914955139
Output for 7.3.16
in_array: 1.1213271617889 preg: 0.10529804229736
Output for 7.3.15
in_array: 1.0685729980469 preg: 0.10184216499329
Output for 7.3.14
in_array: 1.0960991382599 preg: 0.10159015655518
Output for 7.3.13
in_array: 1.1070928573608 preg: 0.13630795478821
Output for 7.3.12
in_array: 1.2273879051208 preg: 0.10381507873535
Output for 7.3.11
in_array: 1.1099078655243 preg: 0.10496997833252
Output for 7.3.10
in_array: 1.1975879669189 preg: 0.12204384803772
Output for 7.3.9
in_array: 1.1895310878754 preg: 0.10997796058655
Output for 7.3.8
in_array: 1.3818550109863 preg: 0.1050980091095
Output for 7.3.7
in_array: 1.121425151825 preg: 0.10706806182861
Output for 7.3.6
in_array: 1.8714549541473 preg: 0.11975502967834
Output for 7.3.5
in_array: 1.2360339164734 preg: 0.20026707649231
Output for 7.3.4
in_array: 1.1088299751282 preg: 0.10071396827698
Output for 7.3.3
in_array: 1.083368062973 preg: 0.12181377410889
Output for 7.3.2
in_array: 1.1186480522156 preg: 0.10014486312866
Output for 7.3.1
in_array: 1.4395492076874 preg: 0.13989210128784
Output for 7.3.0
in_array: 1.516284942627 preg: 0.14883589744568
Output for 7.2.31
in_array: 1.2077698707581 preg: 0.1350998878479
Output for 7.2.30
in_array: 1.1454749107361 preg: 0.13299012184143
Output for 7.2.29
in_array: 1.1753661632538 preg: 0.15396094322205
Output for 7.2.28
in_array: 1.2441620826721 preg: 0.13163709640503
Output for 7.2.27
in_array: 1.1473548412323 preg: 0.131511926651
Output for 7.2.26
in_array: 1.1596109867096 preg: 0.17165088653564
Output for 7.2.25
in_array: 1.148444890976 preg: 0.13248085975647
Output for 7.2.24
in_array: 1.1245718002319 preg: 0.14037108421326
Output for 7.2.23
in_array: 1.2716200351715 preg: 0.1415491104126
Output for 7.2.22
in_array: 1.1315460205078 preg: 0.13169002532959
Output for 7.2.21
in_array: 1.1296830177307 preg: 0.1308159828186
Output for 7.2.20
in_array: 1.4061031341553 preg: 0.1773419380188
Output for 7.2.19
in_array: 1.2085838317871 preg: 0.12836503982544
Output for 7.2.18
in_array: 1.4993081092834 preg: 0.13354396820068
Output for 7.2.17
in_array: 1.2016639709473 preg: 0.12666511535645
Output for 7.2.16
in_array: 1.1461758613586 preg: 0.12530994415283
Output for 7.2.15
in_array: 1.2167019844055 preg: 0.15636682510376
Output for 7.2.14
in_array: 1.5042660236359 preg: 0.13579797744751
Output for 7.2.13
in_array: 1.7650239467621 preg: 0.13236308097839
Output for 7.2.12
in_array: 1.1764001846313 preg: 0.14769506454468
Output for 7.2.11
in_array: 1.2044110298157 preg: 0.18536496162415
Output for 7.2.10
in_array: 1.2634060382843 preg: 0.21485090255737
Output for 7.2.9
in_array: 1.1165370941162 preg: 0.1273078918457
Output for 7.2.8
in_array: 1.1540081501007 preg: 0.12901401519775
Output for 7.2.7
in_array: 1.1098711490631 preg: 0.13311910629272
Output for 7.2.6
in_array: 1.0839381217957 preg: 0.12970399856567
Output for 7.2.5
in_array: 1.1200969219208 preg: 0.14933300018311
Output for 7.2.4
in_array: 1.1704170703888 preg: 0.14447808265686
Output for 7.2.3
in_array: 1.1092450618744 preg: 0.14456415176392
Output for 7.2.2
in_array: 1.1050860881805 preg: 0.13194894790649
Output for 7.2.1
in_array: 1.1923429965973 preg: 0.19634580612183
Output for 7.2.0
in_array: 1.1934421062469 preg: 0.19377613067627