3v4l.org

run code in 300+ PHP versions simultaneously
<?php $currencies = [ 'USD', 'BTC', 'DASH', 'LTC', 'SC', 'STEEM', 'WAVES', 'SNGLS', '1ST', 'BQX', 'ETH', 'PTOY', 'XAUR', ]; $input = [ "BTCUSD", "DASHBTC", "DOGEUSD", "LTCBTC", "LTCUSD", "SCBTC", "STEEMBTC", "WAVESBTC", "SNGLSBTC", "1STBTC", "DASHUSD", "BQXETH", "PTOYETH", "XAURETH", "BTCUSDT", ]; $output=[]; function filterCurrency($doubleCurrency, $key){ global $output; global $currencies; foreach($currencies as $currency){ $pattern = '/^'.$currency. '/'; preg_match($pattern, $doubleCurrency, $matches); if(array_key_exists(0, $matches)){ $output[]=$matches[0]; } } } array_walk_recursive($input, 'filterCurrency'); var_dump($output);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
array(14) { [0]=> string(3) "BTC" [1]=> string(4) "DASH" [2]=> string(3) "LTC" [3]=> string(3) "LTC" [4]=> string(2) "SC" [5]=> string(5) "STEEM" [6]=> string(5) "WAVES" [7]=> string(5) "SNGLS" [8]=> string(3) "1ST" [9]=> string(4) "DASH" [10]=> string(3) "BQX" [11]=> string(4) "PTOY" [12]=> string(4) "XAUR" [13]=> string(3) "BTC" }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array(14) { [0]=> string(3) "BTC" [1]=> string(4) "DASH" [2]=> string(3) "LTC" [3]=> string(3) "LTC" [4]=> string(2) "SC" [5]=> string(5) "STEEM" [6]=> string(5) "WAVES" [7]=> string(5) "SNGLS" [8]=> string(3) "1ST" [9]=> string(4) "DASH" [10]=> string(3) "BQX" [11]=> string(4) "PTOY" [12]=> string(4) "XAUR" [13]=> string(3) "BTC" }

preferences:
168.23 ms | 402 KiB | 202 Q