Jump to content
php.lv forumi

fopen - read


Mikijs

Recommended Posts

<?
$fh = fopen("/home/user/user.csv", 'r');
while($theData=fgets($fh)){
 $count++;
 echo $count."-> $theData<br>";
}
fclose($fh);
?>

 

kapec es nedabunu faila stauru?

- staura ir vairak ka 1000 rindinjas un tapec butu jabut..

Link to comment
Share on other sites

ok velviens qvestions :)

 

- par salidzinasanu

 

<?
$fh2 = fopen("http://localhost/users2.csv", 'r');
while($theData2=fgets($fh2)){
 $i++;
 $array[$i]=true;
}
fclose($fh2);
$fh = fopen("http://localhost/users.csv", 'r');
$c=0;
while($theData=fgets($fh)){
 $count++;
 if($array[$count]==true) $alive="true";
 else $alive="false";
 $c=$c+1;
 if($c==2) {$c=0;$color="#f2f2f2";}
 else {$color="#fdfdf3";}
 $theData=str_replace("\"", "", $theData);
 echo "<tr style='background-color:$color;'>
<td>$count</td>
<td><strong>$theData</strong></td>
<td>$alive</td>
 </tr>";
}
fclose($fh);
?>

 

Tipa salidzina vai faila kontents ir vienads bet tiklidz es izdzesisu kadu no "users2.csv' ierakstiem tad tas un visi nakamie adisies ka FALSE.. ka lai mekle failaa ?

 

piemeram (neeksistejosas funkcijas)

 

$text="test";

if(search_in_file($text, $file)) echo true;

else echo false;

 

ka var shadi ?

Link to comment
Share on other sites

×
×
  • Create New...