<?php $str = "50+16-0*387/2+49"; $digits = []; $symbols = []; preg_match_all("/(\d+)|(\D+)/", $str, $matches, PREG_SET_ORDER); foreach ($matches as $match) { if ($match[1] !== '') { $digits[] = $match[1]; } else { $symbols[] = $match[2]; } } var_export($digits); echo "\n---\n"; var_export($symbols);
You have javascript disabled. You will not be able to edit any code.