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{12})(?=\D|$)/m', $str, $matches); $items = array(); foreach( $matches[2] as $k => $upc) { $items[$upc] = $matches[1][$k]; } print_r($items);
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Array ( [123456789012] => NAME OF ITEM [987654321098] => OTHER NAME [567890123456] => NAME )
Output for hhvm-3.10.0

Process exited with code 153.