note 81044 deleted from function.in-array by danbrown

From: Date: Mon, 08 Jun 2009 21:41:47 +0000
Subject: note 81044 deleted from function.in-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-156508@lists.php.net to get a copy of this message
Note Submitter: anonymous at vitut dot us ---- in_array is pretty slow on big arrays, I used isset() instead in one of my projects. It works well if you are building the array yourself. old way... // build some array while (something) $array[] = $value; // use it to check something if (in_array($search, $array)) { // something... } better way... // build some array while (something) $array[$value] = true; // use it to check something if (isset($array[$search])) { // something... } if you are using something like this, the improvement in speed is immense when using isset() instead of in_array()

« previous php.notes (#156508) next »