Re[2]: [PHP-ES] in_array
| From: | Josep Jover | Date: | Thu, 03 Jan 2002 13:09:57 +0000 |
| Subject: | Re[2]: [PHP-ES] in_array | ||
| References: | 1 2 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-17327@lists.php.net to get a copy of this message | ||
Hola Evaristo,
>> Usa array_intersect si tienes PHP >= 4.0.1 para los comunes (devuelve
>> tipo array) y array_diff para los diferentes.
>>
>> Saludos, jas.
>>
Para los que necesiten usar in_array y no dispongan de PHP4...
if (!ereg("^4",phpversion())) {
function in_array($needle,$haystack) { # we have this function in PHP4, so for you PHP3
people
for ($i=0; $i < count($haystack); $i++) {
if ($haystack[$i] == $needle) {
return true;
}
}
}
}
Pepus
------------------------------------------------------
Josep Jover Gibert
Lavínia
Web: http://www.laviniatv.com
Correu-e: jjover@laviniatv.com
Telf: +34 93 272 34 10
Fax: +34 93 272 34 11
------------------------------------------------------