What is the best way to do the following:
I get a path with an AJAX request
e.g. dir1/dir2/dir3/dir4
dir1/dir2/dir3/dir4
I need to present it like this on my we
if all you need to do is explode by forward slash there is a simple solution that works everytime.
check this out
$path = 'dir1/dir2/dir3/dir4'; $array = explode('/', ltrim($path, '/')); print_r($array);
enjoy :D