From:             [EMAIL PROTECTED]
Operating system: Linux RH 7.3
PHP version:      4.3.0RC3
PHP Bug Type:     Arrays related
Bug description:  array_search skips element 0

(My system info at bottom)

Problem:
The following piece of code doesn't work as advertised:

 while ( $cur = mysql_fetch_row( $result ))
        if ( ! array_search( $cur[0], $userIDs ))
          {
            print("Pushing $cur[0]");
            array_push( $userIDs, $cur[0] );
          }
        else
          print( "Ignoring $cur[0]", "/tmp/pushing");

My Solution:
I wrote my own little search method (ignoring Big-Oh consisderations since
I don't know PHP low-level types)

function my_array_search( $findMe, $inMe ){
{
  foreach ( $inMe as $key )
    if ( $key == $findMe )
      return true;

  return false;
}


Relevant system info from phpinfo();

Linux myHostName 2.4.18-18.7.xsmp #1 SMP Wed Nov 13 19:01:42 EST 2002
i686

 './configure' '--with-mysql' '--enable-calendar'
'--with-apxs=/usr/sbin/apxs' '--with-bz2' '--with-curl'
'--enable-track-vars' '--enable-trans-sid' '--with-imap=/usr/local/lib'
'--with-imap-ssl=/lib' '--enable-debug'

Cheers.
-- 
Edit bug report at http://bugs.php.net/?id=21055&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21055&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21055&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21055&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21055&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21055&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21055&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21055&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21055&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21055&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21055&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21055&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21055&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21055&r=isapi

Reply via email to