[pmwiki-users] Re: Re: Conditional Markup enhancement

Patrick R. Michaud pmichaud at pobox.com
Tue Mar 1 15:05:14 CST 2005


On Tue, Mar 01, 2005 at 09:06:50PM +0100, chr at home.se wrote:
> On Tue, 1 Mar 2005, Patrick R. Michaud wrote:
> 
> > > Btw, while I'm being difficult ;-), does ParseArgs() handle arguments such 
> > > as these
> > > 	list=none  "an argument"=oh-no  "another argument"="oh no..."
> > > i.e. may the keyword be quoted as well?
> > 
> > No.  :-)  At the moment keywords can only be letters, digits, 
> > and underscores.  I may add hyphens to the mix.
> 
> Oh, pretty please.. do add hypens (and underscore)...

Ummm, I did say underscores were already allowed. :-)

> Btw, what's the simple php to split up an array so that 
> 	array('', 'a', '+', 'b', 'list', 'non')
> becomes
> 	array('', '+', 'list') and array('a', 'b', 'non')

    $arglist = $args['#'];
    while ($arglist) {
      $argk[] = array_shift($arglist);
      $argv[] = array_shift($arglist);
    }

although instead of creating the separate arrays, I would tend
to just process the arguments in-place, as in:

    while ($arglist) {
      $k = array_shift($arglist); $v = array_shift($arglist);
      // process $k=>$v here
    }

Of course, one would only do this when the order of arguments is
important; if the order isn't important then one would just
use $args[''], $args['+'], or $args['list'] directly.

Pm



More information about the pmwiki-users mailing list