note 25640 deleted from function.in-array by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: bbisgod AT hotmail DOT com 

----

I had a HUGE problem of comparing references to see if they were pointing to the same object.

I ended up using this code!

function in_o_array (&$needle, &$haystack) {
  if (!is_array($haystack)) return false;
  foreach ($haystack as $key => $val) {
    if (check_refs($needle, $haystack[$key])) return true;
  }
  return false;
}

function check_refs(&$a, &$b) {
  $tmp = uniqid("");
  $a->$tmp = true;
  $bResult = !empty($b->$tmp);
  unset($a->$tmp);
  return $bResult;
}

Hope this helps someone have a more productive morning that me! :P
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.