<?php $str = "50+16-0*387/2+49"; $digits = []; $symbols = []; foreach (preg_split("/(\d+)/", $str, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $string) { if (ctype_digit($string)) { $digits[] = $string; } else { $symbols[] = $string; } } var_export($digits); echo "\n---\n"; var_export($symbols);
You have javascript disabled. You will not be able to edit any code.