in_array

From: Date: Thu, 22 Aug 2002 13:04:22 +0000
Subject: in_array
Groups: php.general 
Request: Send a blank email to php-general+get-113611@lists.php.net to get a copy of this message
jochen schultz wrote:
Hi Riccardo,
          if(mysql_num_rows($rty->resu))  {     //result
              $rec = mysql_fetch_array($rty->resu);
                       if(!isset($_SESSION["bkmks"]) ||   
When you save something for the first time, the element of $_SESSION["bkmks"] is a string and you can compare the array $rec with this string.
!in_array($rec, $_SESSION["bkmks"])) {
Than you convert the element into an array
                                  $_SESSION["bkmks"][] = $rec;
  
and AFAIK in_array() can´t compare two arrays, correct me if i am wrong... Greetings Jochen I think I've sorted it out .... at least I know why it doesn't work:
bool in_array ( mixed needle, array haystack [, bool strict]) Searches haystack for needle and returns TRUE if it is found in the array, FALSE otherwise. If the third parameter strict is set to TRUE then the in_array() function will also check the types of the needle in the haystack. Note: If needle is a string, the comparison is done in a case-sensitive manner. Note: In PHP versions before 4.2.0 needle was not allowed to be an array. PHP on the server is 4.1.2 !!! Is a foreach loop the only thing that I can do??? regards Ricky

« previous php.general (#113611) next »