Re: busqueda

From: Date: Fri, 29 Dec 2000 19:41:26 +0000
Subject: Re: busqueda
References: 1 2 3  Groups: php.general.es 
Request: Send a blank email to general-es+get-5370@lists.php.net to get a copy of this message
Divendres 29 Desembre 2000 20:16, J.Alfonso Martinez Devesa dixit: > Gracias por todos. > > lo de abrir el fichero ya lo tenia ahora lo que hare sera un fgets() y > luego un strpos() .. lo quiero solo para que me diga si una cadena esta > dentro del archivo. > > Este seria un tipo de archivo > > Whois Server Version 1.3 Domain names in the .com, .net, and .org domains > can now be registered with many different competing registrars. Go to > http://www.internic.net for detailed information. No match for > "LABOMBAAAAAAAA.COM". >>> Last update of whois database: Thu, 28 Dec 2000 > 12:25:19 EST <<< The Registry database contains ONLY .COM, .NET, .ORG, .EDU > domains and Registrars. > > Entonces busco su aparece el texto No match for si aparece darle un valor > true y si no false. > > UN SALUDO De acuerdo, puedes usar una función parecida a esta: <? function cadena_en_archivo($cadena, $archivo) { if (! file_exists($archivo)) { echo "El archivo <i>$archivo</i> no existe!"; exit; } if (! ($h = fopen($archivo, 'r'))) { echo "El archivo <i>$archivo</i> no puede leerse!"; exit; } while (! feof($h)) { $linea = fgets($h, 1024); if (! (strpos($linea, $cadena) === false)) { fclose($h); return true; } } fclose($h); return false; } ?> La he escrito sobre la marcha, o sea que no está probada.... Saludos. Àngel

« previous php.general.es (#5370) next »