Tetris-ing an array

Viewed 3149

Consider the following array:

/www/htdocs/1/sites/lib/abcdedd
/www/htdocs/1/sites/conf/xyz
/www/htdocs/1/sites/conf/abc/def
/www/htdocs/1/sites/htdocs/xyz
/www/htdocs/1/sites/lib2/abcdedd

what is the shortest and most elegant way of detecting the common base path - in this case

/www/htdocs/1/sites/

and removing it from all elements in the array?

lib/abcdedd
conf/xyz
conf/abc/def
htdocs/xyz
lib2/abcdedd
16 Answers
Related