- var_dump: documentation ( source)
- preg_match: documentation ( source)
- substr_replace: documentation ( source)
- strrpos: documentation ( source)
<?php
$urlKey = 'ftrcvgbhnjk-2000-4628-20.html';
$oldUrlKey = null;
if (preg_match('/^.*-[0-9]+(-[0-9]+)\.html$/', $urlKey, $matches)) {
$oldUrlKey = substr_replace($urlKey, '', strrpos($urlKey, $matches[1]), strlen($matches[1]));
$index[$oldUrlKey] = '----';
}
var_dump($matches);
echo $oldUrlKey;