- var_dump: documentation ( source)
- preg_match: documentation ( source)
- substr_replace: documentation ( source)
- strrpos: documentation ( source)
<?php
$urlKey = 'ftrcvgbhnjk-2000-4628-20.html';
/**
* Needed for backward compatibility reasons, ensure correct resolving of old product urls
* Removes the category part of the url villa-3565-67.html => villa-3565.html and indexed the old url
*/
$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] = $data;
}
var_dump(oldUrlKey, $matches);