- preg_match: documentation ( source)
- print_r: documentation ( source)
- preg_replace: documentation ( source)
<?php
function get_numerics ($str) {
$matches = array();
preg_match("/\[([^]]*)\]/", $str, $matches);
$matches = preg_replace("/[^0-9]/", '', $str);
return ($matches);
}
$one = 'SP1-SP200';
print_r(get_numerics($one));