Hi I would like to get all numbers after the last instance of – in php
my code is like so at the moment
$results = array();
$pattern = '/[^\-]*$/';
$pattern_no_chars ="[!0-9]";
preg_match($pattern, $alias_title, $matches);
if(count($matches) <1){
return $results;
}
$last_id = end($matches);
$id_no_char = preg_replace($pattern_no_chars, '', $last_id);
For example a url may be /image/view?alias_title=birkenhead-park-15-v-lymm-49-00601jpg-6514
in this case i would want 6514
You can also use
Here’s the breakdown:
And here’s an example
Finally, here’s the output:
1593