- substr_replace: documentation ( source)
- floor: documentation ( source)
<?php
$stringToReplace = "opening-ceremony-600x450.d20140220-u162540.jpg'";
$removeTimestamp = strlen($stringToReplace);
$removeTimestamp = floor($removeTimestamp - 22);
$string = substr_replace($stringToReplace, "jpg",$removeTimestamp);
echo $string;