note 57991 deleted from function.in-array by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: adunaphel at il dot fontys dot nl 

----

a rewrite of alex at alexelectronics dot com's code, with the strict option added and some slight improvements in speed and readability:
<?php
  function in_multi_array ($needle, $haystack, $strict) {
    if ($strict) {
      foreach ($haystack as $item) {
        if (is_array ($item)) {
          if (in_multi_array ($needle, $item, $strict)) {
            return true;
          }
        } else {
          if ($needle === $item) {
            return true;
          }
        }
      }
    } else {
      foreach ($haystack as $item) {
        if (is_array ($item)) {
          if (in_multi_array ($needle, $item, $strict)) {
            return true;
          }
        } else {
          if ($needle == $item) {
            return true;
          }
        }
      }
    }
    return false;
  }
?>
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.