[pmwiki-users] php question

Peter & Melodye Bowers pbowers at pobox.com
Thu Feb 7 16:05:28 CST 2008


> what is the best way to say in php: Remove everything after the last
> slash (including the slash)
> 
> I need this for a backlink in the wikigallerys image view.
>     Group/Name/Imagename -> Group/Name

There is a basename() and dirname() function in PHP which handles situations
like this pretty effectively.  They are obviously designed for actual
pathnames where pagenames may be slightly different (i.e., group.page is
valid syntax, I believe), but I think in most cases they would work nicely.

I have released a new version of Cookbook/WikiSh which contains these
functions as Markup Expression (they are identically named in shell script):

{(basename group/page)}

Returns "page"

{(dirname group/page)}

Returns "group"

-Peter




More information about the pmwiki-users mailing list