3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str = 'NAME OF ITEM 123456789012 OTHER NAME 987654321098 NAME 567890123456'; preg_match_all( '/^(.*?)\s+(\d+)/m', $str, $matches); $items = array(); foreach( $matches[2] as $k => $upc) { $items[$upc] = $matches[1][$k]; } print_r( $items);
Output for 5.2.14 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [123456789012] => NAME OF ITEM [987654321098] => OTHER NAME [567890123456] => NAME )