Re[2]: [PHP] Comparing string to array
| From: | Richard Davey | Date: | Tue, 19 Jun 2007 13:08:51 +0000 |
| Subject: | Re[2]: [PHP] Comparing string to array | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257399@lists.php.net to get a copy of this message | ||
Hi Stut,
Tuesday, June 19, 2007, 1:49:53 PM, you wrote:
>> Very nice, thank you. I was hoping there would be a way to do it
>> without resorting to eval(), but if even you can't figure out how, I'm
>> not going to waste any more time trying to either :)
> You probably could by breaking it into each part and then using a loop
> to descend to the right place, but I don't think that's going to be any
> better than using eval.
I was wondering about doing something like this:
Recurse through $_POST, grabbing all of the keys, and then building a
string from them, something like:
icecream_batch2_flavours
and then storing the value of 'flavours' in a new array with the above
as the key.
Then I could manipulate the form input name:
name="icecream[batch2][flavours][]"
or
name="icecream['batch2']['flavours'][]"
To resemble the above key relatively simply.
Cheers,
Rich
--
Zend Certified Engineer
http://www.corephp.co.uk
"Never trust a computer you can't throw out of a window"