- preg_match: documentation ( source)
- str_replace: documentation ( source)
<?php
$urlKey = 'dfbhkjdsfhsdkfkj-565576-786.html';
$oldUrlKey = null;
if (preg_match('/^.*-[0-9]+(-[0-9]+)\.html$/', $urlKey, $matches)) {
$oldUrlKey = str_replace($matches[1], '', $urlKey);
}
echo $urlKey;
echo $oldUrlKey;