<?php $strings = [ 'CPC >= $0 (Yesterday)', 'CPC (Link) > $100 (Today)' ]; foreach ($strings as $string) { list($metric, $sign, $digit, $time) = preg_match('~([\w ()]+) ([><]=?) \$(\d+) \(([^)]+)\)~', $string, $out) ? array_slice($out, 1) : ['', '', '', '']; echo "metric: $metric, sign: $sign, digit: $digit, time: $time\n"; var_export($metric); // notice no leading or trailing spaces / unwanted characters in the output echo "\n"; var_export($sign); // notice no leading or trailing spaces / unwanted characters in the output echo "\n"; var_export($digit); // notice no leading or trailing spaces / unwanted characters in the output echo "\n"; var_export($time); // notice no leading or trailing spaces / unwanted characters in the output echo "\n----------\n"; }
You have javascript disabled. You will not be able to edit any code.