- This topic is empty.
Viewing 12 posts - 1 through 12 (of 12 total)
Viewing 12 posts - 1 through 12 (of 12 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
HI everyone i’m trying to remove any character after the last occur of a / in a php variable making the result an other variable, i’m having trouble by deleting the content after the slash the only solution that came to my head is this
$result = substr($baseurl, 0, stripos($baseurl, "/") );
that obviously doesent work as it deletes after the first slash.
any help whould be really appreciated
@KarimCossutti – Have you tried rtrim? http://php.net/manual/en/function.rtrim.php
@KarimCossutti – I just found this on another site
string input = "http://www.somesite.com/somepage.aspx?whatever";
int index = input.LastIndexOf("/");
if (index > 0)
input = input.Substring(0, index); // or index + 1 to keep slash
Hi and thanks chris i tried to use the rtrim function but this is the result
$url = 'http://www.domain.ext/subf/page.html';
$result = rtrim($url, "/"); // Gives me the entire url
I want to point out that PHP is total voodoo to me i try to understand the best i can…
@KarimCossutti – are you just trying to get the directory?
Example:
http://www.domain.ext/subf/page.html’;
would then become:
http://www.domain.ext/subf/
??
yeah
but it must work also with multiple sub folders
Eg:
http://www.domain.ext/subf/something.php
http://www.domain.ext/subf/
http://www.domain.ext/subf/ssubf/something.php
http://www.domain.ext/subf/ssubf/
$string = '/tralala/bleh';
$plorp = substr(strrchr($string,'/'), 1);
$string = substr($string, 0, - strlen($plorp));
You can go 2 ways with this. Either use dirname() or use htaccess.
thanks Johan that worked
Another solution
Fixed