|  | Posted by David TG on 09/18/07 04:29 
Hiya!
 I would like to take a partial slice of a fairly complex array.  The
 source looks something like
 
 array
 (
 [Full Name] ==> array
 (
 [p_id] ==> NN
 [field1] ==> blah
 [fieldN] ==> blah
 [numbers] ==> array
 {
 [800-555-1212] ==> "cell"
 [123-456-7890] ==> "home"
 ]
 [emails] ==> array
 (
 [email@add.re.ss] ==>
 [e.mail@addr.ess] ==>
 )
 )
 )
 
 for many fields 1-N across many people.  I want to end up with an
 array like
 
 array
 (
 [Full Name] ==> array
 (
 [display] ==> "Full Name"
 [link] ==> "http://example.com/p_id=NN"
 )
 )
 
 combining some pieces from the source array and adding other pieces
 either constructed (eg link) or static (maybe).
 
 Is there an easy way to do this across my entire source array without
 just looping over it myself?
 
 Why would I do this, you ask?  Well, I have to print a list a bunch of
 times and I am tired of rewriting the code :-)  I'll need to be able
 to specify display value, link target, and/or form field name for
 starters; a separate array will control how to present the data so
 that I can end up with anything from a space-separated list to a row
 in a table to a bunch of checkboxes or radio buttons and so on.  I'm
 certainly open to simpler ways to accomplish the same thing, but a
 function that takes data and control arrays and handles the
 presentation certainly seems nice at the moment :-)
 
 
 TIA & HAND
 
 P.S. -- This is my first post-by-google, so I'm interested in seeing
 how the formatting comes out.  Wish me luck :-)
 
 :-D
 --
 David T-G
 see http://justpickone.org/email/
 [Back to original message] |