The goal:
To match the array VALUES returned from an HTML form of checkboxes,
against the KEYS of another array (array2),
and when I get a match I get the value of the other array(array2) as my output.
Any suggestions?
Thanks,
Don
array_walk(), array_search()
Moderator: General Moderators
- dstefani
- Forum Contributor
- Posts: 140
- Joined: Sat Jan 11, 2003 9:34 am
- Location: Meridian Idaho, USA
I hate when I do that -
Ask for help and then go and figure it out.
Here's what I did, this didn't work before, I must have had typo?
The larger array is on the outside.
The form array is on the inside.
The echo is just for testing.
12 hours is a long enough day for today.
If you know of a more 'elegant' way to do this, by all means share brother and sisters!
- D
Ask for help and then go and figure it out.
Here's what I did, this didn't work before, I must have had typo?
Code: Select all
foreach ($arr_custView as $key => $value)
{
foreach ($form_array as $key2 => $value2)
{
if($key == $value2)
{
echo "$value<br>\n";
}
}
}The form array is on the inside.
The echo is just for testing.
12 hours is a long enough day for today.
If you know of a more 'elegant' way to do this, by all means share brother and sisters!
- D
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
maybe...
Code: Select all
foreach ($arr_custView as $key => $value)
{
if(in_array($key, $form_array)){
echo $form_arrayї$value]."<br>\n";
}
}- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
oh try this...
Code: Select all
foreach ($arr_custView as $key => $value)
{
if(in_array($key, $form_array)){
echo $value."<br>\n";
}
}