array_walk(), array_search()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

array_walk(), array_search()

Post by dstefani »

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
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Post by dstefani »

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?

Code: Select all

foreach ($arr_custView as $key => $value) 
{
    foreach ($form_array as $key2 => $value2) 
    {
        if($key == $value2)
        {
            echo "$value<br>\n";
        &#125;
    &#125;
&#125;
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
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

maybe...

Code: Select all

foreach ($arr_custView as $key => $value) 
&#123; 
    if(in_array($key, $form_array))&#123;
            echo $form_array&#1111;$value]."<br>\n"; 
     &#125;
&#125;
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Post by dstefani »

Thanks, but nope, that didn't work.
At this late hour i don't know why.

Thanks,

- D
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

oh try this...

Code: Select all

foreach ($arr_custView as $key => $value) 
&#123; 
    if(in_array($key, $form_array))&#123; 
            echo $value."<br>\n"; 
     &#125; 
&#125;
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Post by dstefani »

OK, I'll grant you that one Jedi, but can you answer the mystery of the
"form in the popup window sending it's data to the opener and then closing, that works in both IE and NS"?

Thanks

(OT, I know, but hey... )
Post Reply