Giedrius Giedrius - 1 year ago 47
PHP Question

Remove 3 first characters of the string

I have this code that shows all the directories in the previous page.

$dirs = array_filter(glob('../*'), 'is_dir');

foreach ($dirs as $nav) {
echo "<li><a href='$nav'>".$nav."</a></li>";

The output is like this:

  • ../Gėlės

  • ../dddd

  • ../images

Is there a function or a way that could be used removing
prefix from the output string ?

Thank you.


You'll probably get all kinds of wacky string manipulation answers, so here is the proper tool:


Also, use GLOB_ONLYDIR flag as the second argument in your glob() call if you only want directories.