AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters > Web Development
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Web Development Java/PHP/Perl/ASP and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Oct 27, 2002, 16:58   #1
В бой аргхххххххх!
 
hov's Avatar
 
Join Date: Sep 2002
Location: Vik, Medieval Norway
Posts: 1,487
Rep Power: 6
Reputation: 48
Send a message via ICQ to hov
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?
__________________
Rock Hovhannes.

Дневник
Stryfe.Am - Coming Soon!
hov is offline   Reply With Quote Quote selected
Old Oct 27, 2002, 17:54   #2
¡no pasaran!
 
dolphin's Avatar
 
Join Date: Mar 2002
Location: localhost
Posts: 538
Rep Power: 7
Reputation: 23
Send a message via ICQ to dolphin
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 ]
dolphin is offline   Reply With Quote Quote selected
Old Oct 27, 2002, 21:09   #3
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
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;;
}
?>
__________________
[x]-=-[ ]-=-[x]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Oct 27, 2002, 22:00   #4
¡no pasaran!
 
dolphin's Avatar
 
Join Date: Mar 2002
Location: localhost
Posts: 538
Rep Power: 7
Reputation: 23
Send a message via ICQ to dolphin
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
__________________
[ que fors aus ne le sot riens nee ]
dolphin is offline   Reply With Quote Quote selected
Old Oct 27, 2002, 22:36   #5
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
Post

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

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

Так что мы квиты
__________________
[x]-=-[ ]-=-[x]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Nov 2, 2002, 04:08   #6
В бой аргхххххххх!
 
hov's Avatar
 
Join Date: Sep 2002
Location: Vik, Medieval Norway
Posts: 1,487
Rep Power: 6
Reputation: 48
Send a message via ICQ to hov
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!
hov is offline   Reply With Quote Quote selected
Old Nov 3, 2002, 08:46   #7
Младенец
 
Join Date: Nov 2002
Location: Wild Wild West
Posts: 17
Rep Power: 0
Reputation: 10
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 !
Dark is offline   Reply With Quote Quote selected
Old Nov 4, 2002, 12:02   #8
В бой аргхххххххх!
 
hov's Avatar
 
Join Date: Sep 2002
Location: Vik, Medieval Norway
Posts: 1,487
Rep Power: 6
Reputation: 48
Send a message via ICQ to hov
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.
__________________
Rock Hovhannes.

Дневник
Stryfe.Am - Coming Soon!
hov is offline   Reply With Quote Quote selected
Old Nov 5, 2002, 02:24   #9
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
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]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Nov 5, 2002, 04:05   #10
Младенец
 
Join Date: Nov 2002
Location: Wild Wild West
Posts: 17
Rep Power: 0
Reputation: 10
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 ! :-(
--
Dark is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 15:17.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link