Jump to content

remove everything after the last symbol


matthew9090

Recommended Posts

lets say i have this string: dir/dir/dir/dir/dir

 

how would i remove everything after the last '/' sign so it outputs this: dir/dir/dir/dir (and removes the '/' symbol aswell)

 

<?php
//something like this
$str = "dir/dir/dir";
$replace = //do something
echo $replace;
?>

 

EDIT: i found the solution

<?php
$str = "dir/dir/dir";
$replace = dirname($str);
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/239055-remove-everything-after-the-last-symbol/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.