- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$str = <<<FOO
a: 1
b: 2
c: 3
FOO;
preg_match_all('/(\w+): (\d+)/', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
print_r($matches);
preg_match_all('/(\w+): (\d+)/', $str, $matches, PREG_SET_ORDER);
print_r($matches);