I would do substr($x, 0, strpos('/', $x) + 1);
substr($x, 0, strpos('/', $x) + 1);
i.e. everything from the start of the string up until the first /
/