note 24082 deleted from function.in-array by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: robe_NO_SPAM at post_NO_SPAM dot cz 

----

In contribution of <[email protected]>:

 I think we should use more general approach while walking through array, so instead your 'for' loop I'd suggest while list.. as follows:

function in_multi_array($needle, $haystack) //taken from php.net, adapted                                            {                                                                                                                                                                                                                                             $in_multi_array = false;                                                                                                 if(in_array($needle, $haystack))                                                                                         {                                                                                                                     $in_multi_array = true;                                                                                             }                                                                                                                    else                                                                                                                 {                                                                                                                                                                                    while (list($tmpkey,$tmpval) = each ($haystack))                                                                        //here is the change 
{                                                                                                          if(is_array($haystack[$tmpkey])){                                                                                           if (in_multi_array($needle, $haystack[$tmpkey]))                                                                             {                                                                                                                     $in_multi_array = true;                                                                                              break;                                                                                                              }                                                                                                            }                                                                                                            }                                                                                                                }                                                                                                           return $in_multi_array;                                                                                           }       

I hope code is readible, some problems with formatting occured.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.