Just add an else statement that creates the that key, then point to that key for the next iteration.
//This changes the pointer to the leaf foreach($query as $i) { if(isset($pointer[$i])) $pointer = &$pointer[$i]; else { $pointer[$i] = ""; $pointer = &$pointer[$i]; } I should probably ask if this is for a PmWiki recipe or something having to do with PmWiki. It's become quite a long thread, and this mailing list is for PmWiki development discussions. So if it's just a general php question, it might be better to continue our discussion elsewhere. Avast! Daniel Roesler diaf...@gmail.com On Sat, Feb 7, 2009 at 7:20 AM, Hans <desi...@softflow.co.uk> wrote: > Friday, February 6, 2009, 4:29:06 PM, Daniel wrote: > >> //This changes the pointer to the leaf >> foreach($query as $i) { >> if(isset($pointer[$i])) >> $pointer = &$pointer[$i]; > > Daniel, one big problem popped up with this: > > if $pointer[$i] is not set, it will just go to the next key. > > But I would like it to be created first, then go to the next key > for the newly created key. That way we will not loose members, but > add them to the chain if they are not there in the first place. > Like having new directories created automatically if the filepath > string contains new names. > > Is that possible? > > > Hans > > _______________________________________________ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-devel