Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Webmaster Zone > Web Development
Register

Reply
 
LinkBack Thread Tools
Old 27.10.2002, 17:58   #1
В бой аргхххххххх!
 
hov's Avatar
 
Join Date: 09 2002
Location: Vik, Medieval Norway
Age: 35
Posts: 1,513
Downloads: 12
Uploads: 0
Reputation: 43 | 3
Post another php question

Code:
$fp = fopen ("kuku.txt", "r");
while (!feof ($fp)) {
        $a="";
        $i=0;
        while( strlen($a) == $i*200)
        {
            $a .= fgets($fp, 201);
            $i += 1;
        } 
        print $a.&quot;<br>&quot;;
}
fclose ($fp);
kuku.txt - i mej togher en voronq verjanum en \n -ov (LF,CR). Amenaverji toghn el a verjanum \n-ov.
Harc: Inchi a-i verji arjeqy veradardznum a datark togh?
Reply With Quote
Old 27.10.2002, 18:54   #2
¡no pasaran!
 
dolphin's Avatar
 
Join Date: 03 2002
Location: localhost
Age: 35
Posts: 540
Downloads: 0
Uploads: 0
Reputation: 13 | 4
Post

tak, vo pervyx '\n' eto ne <CR><LF> a <LF>, <CR> eto '\r'.

Vo vtoryx fgets chitaet vse libo do konca stroki (prichem koncom schitaetsja ne tol'ko \n kak v unixe no i \r\n kak v windowse) i vydaet vmeste s etim koncom, libo do znachenija vtorogo parametra, tak chto to chto ty tam ponapisal voobsche ne imeet nikakogo smysla. TY chto xochesh' sdelat'? file prochitat' postrochno?
a mojet togda prosto:
Code:
$do_xrena = 4096;
while(!feof($fp)) 
    echo nl2br(fgets($fp, $do_xrena));
__________________
[ que fors aus ne le sot riens nee ]
Reply With Quote
Old 27.10.2002, 22:09   #3
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

2 DolphiN
По моему какой то смысл в этом все таки есть. Кому до хрена, а кому нет, может этих твоих 4096 байт в данном случае не достаточно. Ведь строка в принципе может быть и длиннее. А его версия будет работать со строками любой длины.

2 Hov
Nayi, sagh harc@ nranuma vor feof() function@ false a linelu aynqan jamanak, michev chkarda EOF symbol@, vor@ vor petqa ditarkes vorpes iskakanic goyutun unecogh simbol. Vor hamozves, mi hat senc ashxatacra:
Code:
 
<?
$fd = fopen (&quot;kuku.txt&quot;, &quot;r&quot;);
while (!feof ($fd)){
        $a=&quot;&quot;;
        $i=0;
        while( strlen($a) == $i*200){
            $a .= fgets($fd, 201);
            $i += 1;
        }
        print $a.&quot; --- &quot;.(feof($fd)?&quot; eof TRUE&quot;:&quot;eof false&quot;)  .&quot;<br>&quot;;
}
?>
Reply With Quote
Old 27.10.2002, 23:00   #4
¡no pasaran!
 
dolphin's Avatar
 
Join Date: 03 2002
Location: localhost
Age: 35
Posts: 540
Downloads: 0
Uploads: 0
Reputation: 13 | 4
Post

abyss << xe-xe! chitaj vnimatel'neee.. esli stroka dninnee, to fgets vernet ee bez new-line -a na konce, sledovatel'no sledujuschij fgets prodoljit chitat' etu-je strochku. tak chto $do_xrena mojet byt' daje =1
Reply With Quote
Old 27.10.2002, 23:36   #5
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Да, совершенно верно. Приношу свои извинения. Я тут час пытался до фн дозвониться чтобы исправить пост, но ты меня опередил Все остальное ( по поводу ЕОФ) остается в силе.

Хе Хе, Долф, если $до_хрена будет = 1, то вооще ни хрена не будет, потому что читает то фгетс $до_хрена-1 байтс == 0 байтс

Так что мы квиты
Reply With Quote
Old 02.11.2002, 05:08   #6
В бой аргхххххххх!
 
hov's Avatar
 
Join Date: 09 2002
Location: Vik, Medieval Norway
Age: 35
Posts: 1,513
Downloads: 12
Uploads: 0
Reputation: 43 | 3
Post

To Abyss.
Ok es henc et el mtatsum ei. Aisinqn es piti kardam EOFy prtrsnem (xosqi fgets-ov) heto nor feof()-y asi vor EOF eghav?. Aveli lav kliner vor inqy aser ardioq hajord kardacveliq simvoly EOFa te che, vor avel angam fgets chanei.
Code:
$fp = fopen (&quot;kuku.txt&quot;, &quot;r&quot;);
while (!feof ($fp)) {

        $a=&quot;&quot;;
        $i=0;
        while( strlen($a) == $i*200)
        {
                $a .= fgets($fp, 201);
                $i += 1;
        }
        if ($a == &quot;&quot; ) echo &quot;uliuliu&quot;;
        if ($a == &quot;\r\n&quot; ) echo &quot;ailiuliu&quot;;
}
fclose ($fp);
Ashxatacnum em windows-um.
Ete kuku.txt-i verji toghy nermutseluc heto Enter em seghmum aisinqn file-i verjum avelanuma CR LF (ete chem sxalvum windows-um (CR,LF)-a avelacvum, is UNIX-um prosto LF) apa tpuma "uliuliu". Hakarak depqum "uliuliu" chi tpum. Ete faili mejteghum 2 angam Enter-em seghmum aisinqn mi hat datark togh em avelacnum tpuma "ailiuliu".

To Dolphin > Vo pervyx ia ne prosil govorit' kakie est' pliusy i minysi u etogo otryvka coda. Vopros byl zadan konkretno.
Vo vtoryx mne ne nado postrochno vyvodit' fail. V etom sluchae ia primerno tak by i postupil (kak ty napisal). Mne nujno poluchit' celuiu stroku proanalizirovat' ee i ...
Mojno konechno poluchat' celuiu stroku ispolzuia fgets($fp, $do_xrena) no eto IMHO "ne krasivo". Tak chto "tak chto to chto ty tam ponapisal voobsche ne imeet nikakogo smysla".
Naschet togo chto \n eto LF a \r eto CR polnost'iu soglasen

P.S. C++ - in halal chi?
__________________
Rock Hovhannes.

Дневник
Stryfe.Am - Coming Soon!
Reply With Quote
Old 03.11.2002, 09:46   #7
Младенец
 
Join Date: 11 2002
Location: Wild Wild West
Posts: 17
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Es chishtn asatc tenc el chhaskaca te et algorithm-@ incha anum, u asem inchi chhaskaca amen angam erb vor achqs @ngnuma 200-in uxxexs hrajarvuma haskana te 200 inch kap uni tox kardalu het ?!?!
en vor 201 et 200+1 et parza no pri chem tut 200 ??
Kam harc@ urish dzev dnenq inchi 200 ?
Isk miguce dzuk@ glxica ptum ?

hov> Ete djvar chi porci bacatres te inch es uzum anes !
Reply With Quote
Old 04.11.2002, 13:02   #8
В бой аргхххххххх!
 
hov's Avatar
 
Join Date: 09 2002
Location: Vik, Medieval Norway
Age: 35
Posts: 1,513
Downloads: 12
Uploads: 0
Reputation: 43 | 3
Post

Es uzum em $a-i mej lriv togh stanam ankax te tvial toghi erkarutiuny inchqan klini. Orinak ete toghi erkaratiuny lini 300 simvol cikly 2 angam kashxati u verjum lriv toghy kgrvi $a-i mej. Isk 200-y ankap mi hat tiva karai dra teghy xosqi 10 grei kam 1000. Imasty ena vor $a-i mej misht veradardzvuma lriv togh ankax toghi erkarutiunic.

Hov.
Reply With Quote
Old 05.11.2002, 03:24   #9
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Sagh xarnashpot@ arajacav nranic vor du @ntegh verjum print es anum et togh@.. dra hamar mardik chen haskanum inchi a petq tenc anel..iskakanic ete qo npatak@ liner et file@ togherov tpel parza vor shat vat eghanak kliner qo grac@..
urish harc vor qez petqa et togher@ arandzin stanal hetaga mshakman hamar..et depqum petqa enqan kardal ktor ktor (tekuz 200baytanoc ktornerov), minchev toghi verj hasnes.. u du henc tencel arel es..hamenayn deps arden algoritmi mej imasta erevum.. kak raz es depqum vochmi $do_xrena ov chi lini.. kareli er nayev urish dzev anel (orinak while enqan anel qani der verjum newline chka), bayc de et arden chashaki harca.
__________________
[x]-=-[ ]-=-[x]
Reply With Quote
Old 05.11.2002, 05:05   #10
Младенец
 
Join Date: 11 2002
Location: Wild Wild West
Posts: 17
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Lav OK haskaca ...
Bayc et depqum 200 byte kardal@ mi qich inperformant-a vorovhetev fgets()-@ inq@ file-ic kam 4096 byte-anoc kardalu kam el 8192 byteanoc bloknerova kardalu aveli shut shut aragin@.

Imigayloc: PHP-i constantneric mekum hastat gratc klini te qani byte-ova lowread-@ arvum. System dependant !
--
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 16:56.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.