- substr: documentation ( source)
- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$re = '/\d{5}/';
$str = '5900062000';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
foreach($matches as $match){
echo(substr($match,0,2));
}