Cum caut in fisiere text
Moderatori: Zamolxe, Moderatori
- Dan Alexandru
- PHPRomania Moderator
- Mesaje: 45
- Membru din: Sâm Apr 05, 2003 1:36 pm
- Contact:
Inceraca asta pentru inceput
<?php
$handle = fopen ("fis.txt","r");
$cuvant="text7";
while (!feof ($handle))
{
$buffer = fgets($handle, 4096);
//echo $buffer;
if(strpos($buffer, $cuvant))
echo $buffer . "\n";
}
fclose($handle);
?>
unde fis.txt :
linia 1 text1 text2 text3
linia 2 text4 text2 text3
linia 3 text5 text2 text3
linia 4 text6 text2 text3
linia 5 text7 text2 text3
<?php
$handle = fopen ("fis.txt","r");
$cuvant="text7";
while (!feof ($handle))
{
$buffer = fgets($handle, 4096);
//echo $buffer;
if(strpos($buffer, $cuvant))
echo $buffer . "\n";
}
fclose($handle);
?>
unde fis.txt :
linia 1 text1 text2 text3
linia 2 text4 text2 text3
linia 3 text5 text2 text3
linia 4 text6 text2 text3
linia 5 text7 text2 text3
- Constantin
- PHPRomania Coder Professional
- Mesaje: 236
- Membru din: Vin Sep 20, 2002 12:38 pm
- Contact:
Cine este conectat
Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 13 vizitatori

