fork download
  1. <?php
  2.  
  3. $s = "levis 5° 501";
  4. preg_match('~^(.*?)\s*(\d+)\D*$~s', $s, $matches);
  5. print_r($matches[1] . ": ". $matches[2]. PHP_EOL);
  6. print_r(preg_split('~\s*(?=\s*\d+\D*$)~', $s, 2));
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
levis 5°: 501
Array
(
    [0] => levis 5°
    [1] => 501
)