3v4l.org

run code in 300+ PHP versions simultaneously
<?php $output = "a b\tc"; $preg_match_matches = NULL; $preg_match_all_matches = NULL; $preg_replace_callback_array_count = NULL; var_dump([ 'preg_filter' => preg_filter('/[a-z]+/', 'X', $output, 0), 'preg_grep' => preg_grep('/^[a-z]+/', [$output, 'x'], 0), 'preg_match' => preg_match('/^[a-z]+/', $output, $preg_match_matches, 0, 0), 'preg_match $matches' => $preg_match_matches, 'preg_match_all' => preg_match_all('/^[a-z]+/', $output, $preg_match_all_matches, 0, 0), 'preg_match_all $matches' => $preg_match_all_matches, 'preg_replace' => preg_replace('/[a-z]+/', 'X', $output, 0), 'preg_replace_callback' => preg_replace_callback('/[a-z]+/', function($word) { return $word; }, $output, 0), 'preg_replace_callback_array' => preg_replace_callback_array([ '~[a]+~i' => function ($match) { return 'X'; }, '~[b]+~i' => function ($match) { return 'Y'; } ], $output, 0, $preg_replace_callback_array_count, 0), 'preg_split' => preg_split('/\s/', $output, 0, PREG_SPLIT_NO_EMPTY), ]); ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.140.0470.00617.45
8.1.00.0230.00917.35
8.0.00.0260.01117.08

preferences:
32.89 ms | 403 KiB | 5 Q