fread
������ �� ��������� ����� ������������ ���������� ��������.
��������� :
string fread(int $f, int $numbytes)
������ �� ����� $f $numbytes �������� � ���������� ������ ���� ��������. ����� ������ ��������� ����� ������������ � ���������� ����� ������������ ����� ��������. ���� $numbytes ������, ��� ����� ��������� �� �����, ������������ ��, ��� ������� �������. ���� ����� ����� ������������, ���� ��� ����� ������� � ������ ���� �������. ��� ����� ������ ������� � $numbytes ����� ������� �����. �� ���� �� ���������� �� �������� ������ � �������, ��� ��������� �� �������������.
������ �� ��������� ����� ������������ ���������� ��������.
��������� :
string fread(int $f, int $numbytes)
������ �� ����� $f $numbytes �������� � ���������� ������ ���� ��������. ����� ������ ��������� ����� ������������ � ���������� ����� ������������ ����� ��������. ���� $numbytes ������, ��� ����� ��������� �� �����, ������������ ��, ��� ������� �������. ���� ����� ����� ������������, ���� ��� ����� ������� � ������ ���� �������. ��� ����� ������ ������� � $numbytes ����� ������� �����. �� ���� �� ���������� �� �������� ������ � �������, ��� ��������� �� �������������.
fwrite
������ � ����.
��������� :
int fwrite(int $f, string $str)
���������� � ���� $f ��� ���������� ������ $str. ��� ������� ���������� ���� ��� fread(), �������� "� �������� �����������".
��� ������ � ���������� ������� (�� ���� ����� ������ ������ t � ������ �������� �����) ��� \n ������������ ������������� � ��� ����������� �����, ������� ������ � ����� ������������ �������.
������ � ����.
��������� :
int fwrite(int $f, string $str)
���������� � ���� $f ��� ���������� ������ $str. ��� ������� ���������� ���� ��� fread(), �������� "� �������� �����������".
��� ������ � ���������� ������� (�� ���� ����� ������ ������ t � ������ �������� �����) ��� \n ������������ ������������� � ��� ����������� �����, ������� ������ � ����� ������������ �������.
fgets
������ �� ����� ���� ������, ��������������� �������� ����� ������ \n.
��������� :
string fgets(int $f, int $length)
���� ������ ����� ����������� � ���������� � ���������. ���� ������ � ����� �������� ������ $length-1 ������, �� ������������ ������ �� $length-1 ��������. ������� �������, ���� �� ������� ���� � ������ "��������" �� ���� �� �������. ������ ���� � ���� ������ (� �������) ����� ��������������� �������� File(). ����� ����� ��������, ��� ��� ������� (��� � ������� fread()) � ������ ���������� ������ � Windows ���������� � �������������� ��� \r\n � ���� ������ \n.
������ �� ����� ���� ������, ��������������� �������� ����� ������ \n.
��������� :
string fgets(int $f, int $length)
���� ������ ����� ����������� � ���������� � ���������. ���� ������ � ����� �������� ������ $length-1 ������, �� ������������ ������ �� $length-1 ��������. ������� �������, ���� �� ������� ���� � ������ "��������" �� ���� �� �������. ������ ���� � ���� ������ (� �������) ����� ��������������� �������� File(). ����� ����� ��������, ��� ��� ������� (��� � ������� fread()) � ������ ���������� ������ � Windows ���������� � �������������� ��� \r\n � ���� ������ \n.
fputs
������ ������ fwrite().
��������� :
int fputs(int $f, string $str)
������ ������ fwrite().
��������� :
int fputs(int $f, string $str)
fgetcsv
������� ��� ������ � ����� �� �������� ������, � ������� ����� ��������� ������ Excel.
��������� :
list fgetcsv(int $f, int $length, char $delim=",")
������� ������ ������ �� �����, ��������� ������������ $f, � ��������� �� �� ������� $delim. �������� $delim ������ ����������� ���� ������� �� ������ �������, � ��������� ������ ����������� �� �������� ������ ������ ������ ���� ������. ������� ���������� ������������ ������ ��� false, ���� ������ ���������. �������� $length ������ ������������ ����� ������ ����� ��� ��, ��� ��� �������� � fgets(). ������ ������ � ����� �� ������������, � ������������ ��� ������ �� ������ �������� - ������ ������.
������� ��� ������ � ����� �� �������� ������, � ������� ����� ��������� ������ Excel.
��������� :
list fgetcsv(int $f, int $length, char $delim=",")
������� ������ ������ �� �����, ��������� ������������ $f, � ��������� �� �� ������� $delim. �������� $delim ������ ����������� ���� ������� �� ������ �������, � ��������� ������ ����������� �� �������� ������ ������ ������ ���� ������. ������� ���������� ������������ ������ ��� false, ���� ������ ���������. �������� $length ������ ������������ ����� ������ ����� ��� ��, ��� ��� �������� � fgets(). ������ ������ � ����� �� ������������, � ������������ ��� ������ �� ������ �������� - ������ ������.
������: $f=fopen("file.csv","r") or die("������"); for($i=0; $data=fgetscsv($f, 1000, ";"); $i++) { $num = count($data); if($num==1 && $data[0]==="") continue; echo "<h3>������ ����� $i ($num �����):</h3>"; for($c=0; $c<$num; $c++) print "[$c]: $data[$c]<br>"; } fclose($f);