note 44817 modified in function.in-array by tomsommer

From: Date: Mon, 06 Sep 2004 05:30:51 +0000
Subject: note 44817 modified in function.in-array by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76087@lists.php.net to get a copy of this message
A better (faster) version: <?php function in_array ($item, $array) { $item = &strtoupper($item); foreach($array as $element) { if ($item == strtoupper($element)) { return true; } } return false; } ?> Noah B, set the 3rd argument to true and everything will wokr fine :) 0 == 'foo' is true, however 0 === 'foo' is not. --was-- A better (faster) version: <?php function in_iarray ($item, $array) { $item = &strtoupper($item); foreach($array as $element) { if ($item == strtoupper($element)) { return true; } } return false; } ?> Noah B, set the 3rd argument to true and everything will wokr fine :) 0 == 'foo' is true, however 0 === 'foo' is not. http://php.net/manual/en/function.in-array.php

« previous php.notes (#76087) next »