when i use:
rtrim('HeaderController', 'Controller');
i'm expecting to this will return Header because HeaderController - Controller = Header but this returns 'Head', why?
when i use:
rtrim('HeaderController', 'Controller');
i'm expecting to this will return Header because HeaderController - Controller = Header but this returns 'Head', why?
if you want to remove the "Controller" substring you can do it like this:
$name = 'HeaderController';
$shortName = str_replace('Controller', '', $name);
to be sure to replace only "Controller" in the end of the string you need a regular expression (which is a little slower)
$name = 'HeaderController';
$shortName = preg_replace('/Controller$/', '', $name);
The $-sign marks the end of the string