3v4l.org

run code in 300+ PHP versions simultaneously
<?php // String manipulation (explode and manual comparison) $sstart = microtime(true); for ($i = 0; $i < 100000; $i++) { $uri = 'user/123'; $segments = explode('/', $uri); if ($segments[0] === 'user' && is_numeric($segments[1])) { $id = $segments[1]; } } $string = (microtime(true) - $sstart); echo 'String manipulation: ' . $string . ' seconds'.PHP_EOL; // Regex equivalent $rstart = microtime(true); for ($i = 0; $i < 100000; $i++) { $uri = 'user/123'; if (preg_match('#^user/(\d+)$#', $uri, $matches)) { $id = $matches[1]; } } $regex = (microtime(true) - $rstart); echo 'Regex: ' . $regex . ' seconds'.PHP_EOL; echo 'Diff: '.((($regex - $string) / $string) * 100).'%';
Output for 8.3.11
String manipulation: 0.023391962051392 seconds Regex: 0.014002084732056 seconds Diff: -40.141469530032%
Output for 8.3.10
String manipulation: 0.023142099380493 seconds Regex: 0.016136884689331 seconds Diff: -30.270437335806%
Output for 8.3.9
String manipulation: 0.0087978839874268 seconds Regex: 0.0080370903015137 seconds Diff: -8.6474621283976%
Output for 8.3.8
String manipulation: 0.0096361637115479 seconds Regex: 0.010258913040161 seconds Diff: 6.4626271123537%
Output for 8.3.7
String manipulation: 0.011929988861084 seconds Regex: 0.0089859962463379 seconds Diff: -24.677245293577%
Output for 8.3.6
String manipulation: 0.009876012802124 seconds Regex: 0.0083291530609131 seconds Diff: -15.66279603119%
Output for 8.3.5
String manipulation: 0.017117977142334 seconds Regex: 0.0079340934753418 seconds Diff: -53.650519513078%
Output for 8.3.4
String manipulation: 0.011999130249023 seconds Regex: 0.0080749988555908 seconds Diff: -32.703465267843%
Output for 8.3.3
String manipulation: 0.022521018981934 seconds Regex: 0.019075155258179 seconds Diff: -15.300656362481%
Output for 8.3.2
String manipulation: 0.022005081176758 seconds Regex: 0.017342090606689 seconds Diff: -21.190517465546%
Output for 8.3.1
String manipulation: 0.02119517326355 seconds Regex: 0.012782096862793 seconds Diff: -39.693359880314%
Output for 8.3.0
String manipulation: 0.021157026290894 seconds Regex: 0.019805908203125 seconds Diff: -6.386143634704%
Output for 8.2.23
String manipulation: 0.021914958953857 seconds Regex: 0.018058061599731 seconds Diff: -17.599382057921%
Output for 8.2.22
String manipulation: 0.017475128173828 seconds Regex: 0.010421991348267 seconds Diff: -40.361001964637%
Output for 8.2.21
String manipulation: 0.020665884017944 seconds Regex: 0.01075291633606 seconds Diff: -47.967789199229%
Output for 8.2.20
String manipulation: 0.020730018615723 seconds Regex: 0.01130199432373 seconds Diff: -45.48005704559%
Output for 8.2.19
String manipulation: 0.0088419914245605 seconds Regex: 0.0077970027923584 seconds Diff: -11.818475974761%
Output for 8.2.18
String manipulation: 0.0095291137695312 seconds Regex: 0.0079469680786133 seconds Diff: -16.603282626101%
Output for 8.2.17
String manipulation: 0.023166179656982 seconds Regex: 0.019211053848267 seconds Diff: -17.072844410596%
Output for 8.2.16
String manipulation: 0.0084121227264404 seconds Regex: 0.0080499649047852 seconds Diff: -4.3051894680158%
Output for 8.2.15
String manipulation: 0.018640041351318 seconds Regex: 0.0080080032348633 seconds Diff: -57.038704561152%
Output for 8.2.14
String manipulation: 0.0085809230804443 seconds Regex: 0.0079600811004639 seconds Diff: -7.235142118863%
Output for 8.2.13
String manipulation: 0.026747226715088 seconds Regex: 0.018070936203003 seconds Diff: -32.438093879807%
Output for 8.2.12
String manipulation: 0.020046949386597 seconds Regex: 0.0080990791320801 seconds Diff: -59.59944340711%
Output for 8.2.11
String manipulation: 0.021255016326904 seconds Regex: 0.0141921043396 seconds Diff: -33.22938867078%
Output for 8.2.10
String manipulation: 0.0089139938354492 seconds Regex: 0.0080878734588623 seconds Diff: -9.2676794693485%
Output for 8.2.9
String manipulation: 0.009382963180542 seconds Regex: 0.01085901260376 seconds Diff: 15.731165036209%
Output for 8.2.8
String manipulation: 0.011677026748657 seconds Regex: 0.009544849395752 seconds Diff: -18.259591236703%
Output for 8.2.7
String manipulation: 0.0089001655578613 seconds Regex: 0.0081191062927246 seconds Diff: -8.7757835521029%
Output for 8.2.6
String manipulation: 0.0086429119110107 seconds Regex: 0.0079278945922852 seconds Diff: -8.2728752310281%
Output for 8.2.5
String manipulation: 0.02475905418396 seconds Regex: 0.017668008804321 seconds Diff: -28.640211079762%
Output for 8.2.4
String manipulation: 0.013768196105957 seconds Regex: 0.014410018920898 seconds Diff: 4.6616333033179%
Output for 8.2.3
String manipulation: 0.0095450878143311 seconds Regex: 0.0087959766387939 seconds Diff: -7.8481328837267%
Output for 8.2.2
String manipulation: 0.016084909439087 seconds Regex: 0.0080940723419189 seconds Diff: -49.679092862966%
Output for 8.2.1
String manipulation: 0.008634090423584 seconds Regex: 0.0080080032348633 seconds Diff: -7.2513392610593%
Output for 8.2.0
String manipulation: 0.0208740234375 seconds Regex: 0.0092391967773438 seconds Diff: -55.738304093567%
Output for 8.1.29
String manipulation: 0.0086669921875 seconds Regex: 0.0080330371856689 seconds Diff: -7.3145906690141%
Output for 8.1.28
String manipulation: 0.0087840557098389 seconds Regex: 0.0078999996185303 seconds Diff: -10.064327009201%
Output for 8.1.27
String manipulation: 0.013440132141113 seconds Regex: 0.0081629753112793 seconds Diff: -39.264173703257%
Output for 8.1.26
String manipulation: 0.021610975265503 seconds Regex: 0.018505096435547 seconds Diff: -14.371766159549%
Output for 8.1.25
String manipulation: 0.009274959564209 seconds Regex: 0.0081520080566406 seconds Diff: -12.107346665981%
Output for 8.1.24
String manipulation: 0.0086128711700439 seconds Regex: 0.0080249309539795 seconds Diff: -6.8262975778547%
Output for 8.1.23
String manipulation: 0.020768880844116 seconds Regex: 0.015723943710327 seconds Diff: -24.290847309754%
Output for 8.1.22
String manipulation: 0.021781921386719 seconds Regex: 0.020288944244385 seconds Diff: -6.8542031523643%
Output for 8.1.21
String manipulation: 0.025157928466797 seconds Regex: 0.017648220062256 seconds Diff: -29.85026535254%
Output for 8.1.20
String manipulation: 0.01275110244751 seconds Regex: 0.0083870887756348 seconds Diff: -34.224598930481%
Output for 8.1.19
String manipulation: 0.016660928726196 seconds Regex: 0.012228965759277 seconds Diff: -26.600935876705%
Output for 8.1.18
String manipulation: 0.0089271068572998 seconds Regex: 0.007957935333252 seconds Diff: -10.856501882862%
Output for 8.1.17
String manipulation: 0.0098679065704346 seconds Regex: 0.0081131458282471 seconds Diff: -17.782502597308%
Output for 8.1.16
String manipulation: 0.022052049636841 seconds Regex: 0.013808965682983 seconds Diff: -37.380126063594%
Output for 8.1.15
String manipulation: 0.0089459419250488 seconds Regex: 0.0085411071777344 seconds Diff: -4.5253451308566%
Output for 8.1.14
String manipulation: 0.021787881851196 seconds Regex: 0.017726182937622 seconds Diff: -18.642009082453%
Output for 8.1.13
String manipulation: 0.0089550018310547 seconds Regex: 0.0082120895385742 seconds Diff: -8.2960596379127%
Output for 8.1.12
String manipulation: 0.0086128711700439 seconds Regex: 0.0083401203155518 seconds Diff: -3.1667820069204%
Output for 8.1.11
String manipulation: 0.0091021060943604 seconds Regex: 0.0082180500030518 seconds Diff: -9.7126542158891%
Output for 8.1.10
String manipulation: 0.010105848312378 seconds Regex: 0.0079920291900635 seconds Diff: -20.916790525397%
Output for 8.1.9
String manipulation: 0.0085999965667725 seconds Regex: 0.0080280303955078 seconds Diff: -6.6507720883812%
Output for 8.1.8
String manipulation: 0.0087850093841553 seconds Regex: 0.0082001686096191 seconds Diff: -6.6572583928135%
Output for 8.1.7
String manipulation: 0.0090110301971436 seconds Regex: 0.0081419944763184 seconds Diff: -9.6441328218018%
Output for 8.1.6
String manipulation: 0.022574901580811 seconds Regex: 0.021346092224121 seconds Diff: -5.4432545466067%
Output for 8.1.5
String manipulation: 0.028565883636475 seconds Regex: 0.022116184234619 seconds Diff: -22.578329744437%
Output for 8.1.4
String manipulation: 0.0087971687316895 seconds Regex: 0.0086710453033447 seconds Diff: -1.4336820423871%
Output for 8.1.3
String manipulation: 0.022129058837891 seconds Regex: 0.012921094894409 seconds Diff: -41.610282709878%
Output for 8.1.2
String manipulation: 0.008709192276001 seconds Regex: 0.0081949234008789 seconds Diff: -5.9048974787155%
Output for 8.1.1
String manipulation: 0.0087399482727051 seconds Regex: 0.0080139636993408 seconds Diff: -8.3065088111736%
Output for 8.1.0
String manipulation: 0.022111892700195 seconds Regex: 0.017565011978149 seconds Diff: -20.563055291987%

preferences:
38.92 ms | 505 KiB | 5 Q