Can I use rtrim() here?

I would do substr($x, 0, strpos('/', $x) + 1);

i.e. everything from the start of the string up until the first /

3 Likes