I have a string and I want to replace the last 7 charators of the string with \"#\". For example I have \"MerryChristmasu87yujh7\" I want to replace \"87yujh7\" with seven \
Should be...
$match = substr($string, -7);
... without the final -1. But in fact, it's far better done with...
$result = substr($string, 0, -7) . str_repeat('#', 7);
... or, more generic:
$coverWith = function($string, $char, $number) {
return substr($string, 0, -$number) . str_repeat($char, $number);
};