3v4l.org

run code in 300+ PHP versions simultaneously
<?php function extractVars($pattern){ //Extract if function $array_vars = []; $rgx = '/^(?<startOfS>.*?)\{=IF\((device=mobile|audience IN\(.*?\)),(.*?)\):(.*?)\}(?<endOfS>.*?)$/'; preg_match_all($rgx, $pattern, $matches, PREG_SET_ORDER, 0); print_r($matches); return $array_vars; } $var = extractVars(" Get The Best Shoes At The Best Price. {=IF(device=mobile,Free Shipping on Mobile Orders!):Buy Now!}"); print_r($var);
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.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Array ( [0] => Array ( [0] => Get The Best Shoes At The Best Price. {=IF(device=mobile,Free Shipping on Mobile Orders!):Buy Now!} [startOfS] => Get The Best Shoes At The Best Price. [1] => Get The Best Shoes At The Best Price. [2] => device=mobile [3] => Free Shipping on Mobile Orders! [4] => Buy Now! [endOfS] => [5] => ) ) Array ( )

preferences:
165.17 ms | 404 KiB | 182 Q