$file = \"refinish.php\";
$folder = rtrim($file, \".php\");
echo $folder; // refinis
where is ending h
?
I tried with some other
rtrim()
does not remove the string you specify in the second argument, but all characters in that string. In your case, that includes "h".
What you need here is a simple str_replace()
:
$folder = str_replace('.php', '', $file);
Edit: if you want to make sure it strips the ".php" part only from the end of the $file
, you can go with @racetrack's suggestion below and use preg_replace()
instead:
$folder = preg_replace('/\.php$/', '', $file);