note 44817 modified in function.in-array by aidan

From: Date: Wed, 18 Aug 2004 06:23:58 +0000
Subject: note 44817 modified in function.in-array by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74855@lists.php.net to get a copy of this message
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. --was-- A better (faster) version: <?php function in_array_ci($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 (#74855) next »