Digital-X Posted February 21, 2004 Report Share Posted February 21, 2004 (edited) Mans.txt Iespeeja1 Iespeeja2 Kauktas te un arii te lai izrukaatu rindinjas vajag: $mans_var = file("Mans.txt"); echo "Shii ir ".$mans_var[0]; echo "Bet te ir: ".$mans_var[2]; Bet ko dariit lai ieraxtiitu noteiktajaa rindinjaa? :blink: ...un veel par masiiviem - $arrays_from_explode = explode(",",$fp); $my = array($arrays_from_explode); if ($_POST['blah'] = $my){ echo "Kautkas te" } else { echo "nekaa te nav :P" } ..shitaads skriptijs nestraadaa, es gribu, lai vinsh nolasa sho failu saliek pa arrayiem visu kas aiz "," un peec tam paarbauda vai posts sakriit ar kaadu no arrayiem. Edited February 21, 2004 by Digital-X Link to comment Share on other sites More sharing options...
rnc Posted February 22, 2004 Report Share Posted February 22, 2004 (edited) $my = explode(",",$fp); for($i=0;$i<=count($my);$i++) { if ($_POST['blah'] = $my[$i]){ $ir = TRUE; } } if ($ir == TRUE) { echo 'te kaut kas ir '; } else { echo 'te kaut kaa nav;D'; } Nu neesu testeejis, bet domaaju ka jaaiet! Btw shitais ir diezgan pagarsh, imho vareetu arii iisaak! Kaut gan, tiko padomaaju ja $fp = file('mans.txt'); tad tur iznaak pilniigs bulshits. Ieprieksh nebiju ieskatijies.. Tad nu vareetu buut ~ taa (atkal neesu notesteejis, slinkums mani maac) <?php $fp = file('mans.txt'); for($f=0;$f<=count($fp);$f++) { $my = explode (",",$fp[$f]); for ($i=0;$i<=count($my);$i++) { if ($_POST['blah'] == $my[$i]) { $ir = TRUE; } } } if ($ir==TRUE) { echo 'ir, ir, viss kedaaa'; } else { echo 'aij, blje nav;('; } ?> Edited February 22, 2004 by rnc Link to comment Share on other sites More sharing options...
Roze Posted February 23, 2004 Report Share Posted February 23, 2004 Es gan pilniibaa visu nesapratu no pirmaa posta (arii no otraa) bet nu meegjinaashu atbildete pa gabalinjam.. Lai noskaidortu vai veertiba ir arrayaa vinsh nav ar ciklu jaapaarbauda.. Eksistee in_array() http://lv.php.net/in_array Proti ja $my ir arrays tad if(in_array($_POST['blah'],$my)) { ir; } else { nav; } $arrays_from_explode = explode(",",$fp);$my = array($arrays_from_explode); Shis te ir gauzhaam nepareizi.. 1. Balstoties uz pirmo scripta fragmentu $fp = file('mans.txt'); $fp jau tiek izveidots kaa masiivs (arrays) kursh satur katru faila rindinju jaunaa masiiva elementaa.. explode() nepiecieshams strings Liidz ar to $fp = file_get_contents('mans.txt'); 2. Funkcija explode() atgriezh masiivu tapeec veelreiz likt funkcijaa array() masiivu nav pareizi.. Link to comment Share on other sites More sharing options...
rnc Posted February 23, 2004 Report Share Posted February 23, 2004 Lai noskaidortu vai veertiba ir arrayaa vinsh nav ar ciklu jaapaarbauda.. Eksistee in_array() http://lv.php.net/in_array Njaa, esmu nelabojams mulkjis, jau cik reiz vienu un to pashu kljuudu pieljauju :( Link to comment Share on other sites More sharing options...
Digital-X Posted March 1, 2004 Author Report Share Posted March 1, 2004 (edited) bet kaa tad lai ieraxta failaa, noteiktaa rindinjaa :blink: :huh: ? mansfails.txt rinda1 rinda2 rinda3 rinda4 Un es caur formu gribu samainiit, ka piemeeram row[0] (kuraa rindaa) buus raxtiits "mana jaunaa 1. rinda!" Kautko jau atradu :) lai tiktu jaunaa rindinjaa ir jaaraxta \r\n Edited March 1, 2004 by Digital-X Link to comment Share on other sites More sharing options...
рпр Posted March 1, 2004 Report Share Posted March 1, 2004 peec kaada kriteerija tu noteiksi, kuraa rindaa tev to jauno rindu vajag? vispirms tev buus jaanolasa fails un janosaka kruaa vietaa tu to gribi dariit un peec tam ar fseek jaaaiziet failaa uz to vieutu,kuraa tev vajag ierakstiit. Link to comment Share on other sites More sharing options...
Digital-X Posted March 1, 2004 Author Report Share Posted March 1, 2004 atrdadu sho te. <?php $fp = fopen('somefile.txt'); // read some data $data = fgets($fp, 4096); // move back to the beginning of the file // same as rewind($fp); fseek($fp, 0); ?> Laikam jaaliek shaadi... $seeek = fseek($fp, 5); fwrite($fp,$seeek) un tad vinsh ieraxtiis tajaa 5 rindinjaa? Link to comment Share on other sites More sharing options...
рпр Posted March 1, 2004 Report Share Posted March 1, 2004 palasi par seeku helpu, tas nav rindinju skaits, bet gan simbolu skaits. tas kods ko tu tur uzrakstiiji ir galiigi garaam. Link to comment Share on other sites More sharing options...
Digital-X Posted March 1, 2004 Author Report Share Posted March 1, 2004 taadu es redzeeju lv.php.net... varbuut paraadi kaadu piemeeru? Link to comment Share on other sites More sharing options...
trinklins Posted March 5, 2004 Report Share Posted March 5, 2004 īsti pareizi jau nav bet tomēr <?php $mans_var = file("Mans.txt"); $fp= fopen("Mans.txt","w"); $kuraa_rindinjaa = 2; $ko_rakstit = "jaunaaa rindinja"; for ($i=0;$i<count($mans_var)+1;$i++) { if ($i != $kuraa_rindinjaa-1) { fwrite($fp,$mans_var[$i]); } else { fwrite($fp,$ko_rakstit."\r\n"); fwrite($fp,$mans_var[$i]); } } fclose($fp); ?> Link to comment Share on other sites More sharing options...
trinklins Posted March 5, 2004 Report Share Posted March 5, 2004 (edited) kodinsh ir suudigs Edited March 5, 2004 by trinklins Link to comment Share on other sites More sharing options...
Recommended Posts