MM-Y Posted May 24, 2003 Report Share Posted May 24, 2003 Ir dati.txt failinsh. Tajaa infa glabajaas shaadi: sadalja||virsraksts||laiks||teksc piem.: ( abols||abolju zapte||22.02.03||abolju zapti gatavo no aboliem un cukura bumbiers||bumbieru zapte||22.02.03||bumbieru zapti gatavo no bumbieriem un cukura abols||abols zapte ar kreejumu||23.02.03||abolu zapte ir garshiga, ja to eed kopa ar krejumu ). Es velos, lai man no datu faila nolasa tikai taas rindinjas, kuraas ir tas 'abols'. piem.: ( abols||abolju zapte||22.02.03||abolju zapti gatavo no aboliem un cukura abols||abols zapte ar kreejumu||23.02.03||abolu zapte ir garshiga, ja to eed kopa ar krejumu ). Link to comment Share on other sites More sharing options...
Venom Posted May 24, 2003 Report Share Posted May 24, 2003 $dati=@file('dati.txt'); $atbilde=array(); foreach($dati as $line) { if (substr_count('abols||',$line)) {$atbilde[]=$line;} } Link to comment Share on other sites More sharing options...
MM-Y Posted May 24, 2003 Author Report Share Posted May 24, 2003 nu nesanaaca man iisti nekas... parasti izvelku ar kodu <code><font color="#000000"> <font color="#0000CC"><? $fails </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/array_reverse]array_reverse[/url]</font><font color="#006600">(</font><font color="#0000CC">file </font><font color="#006600">(</font><font color="#CC0000">"dati.txt"</font><font color="#006600">)); while (</font><font color="#0000CC">$val </font><font color="#006600">= </font><font color="#0000CC">each </font><font color="#006600">(</font><font color="#0000CC">$fails</font><font color="#006600">)) { </font><font color="#0000CC">$mas </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/explode]explode[/url]</font><font color="#006600">(</font><font color="#CC0000">"||"</font><font color="#006600">,</font><font color="#0000CC">$val</font><font color="#006600">[</font><font color="#0000CC">1</font><font color="#006600">]); print (</font><font color="#CC0000">"<tr><td class="</font><font color="#0000CC">virsraksts</font><font color="#CC0000">">$mas</font><font color="#006600">[</font><font color="#CC0000">0</font><font color="#006600">]</font><font color="#CC0000"> <b>$mas</font><font color="#006600">[</font><font color="#CC0000">1</font><font color="#006600">]</font><font color="#CC0000"></b> $mas</font><font color="#006600">[</font><font color="#CC0000">2</font><font color="#006600">]</font><font color="#CC0000"> </td></tr>n"</font><font color="#006600">); print (</font><font color="#CC0000">"<tr><td class="</font><font color="#0000CC">teksts</font><font color="#CC0000">">$mas</font><font color="#006600">[</font><font color="#CC0000">3</font><font color="#006600">]</font><font color="#CC0000"></td></tr>n"</font><font color="#006600">); } </font><font color="#0000CC">?></font> </font> </code> Kaa lai vinju pielaago tam <code><font color="#000000"> <font color="#0000CC"><? $dati</font><font color="#006600">=@</font><font color="#0000CC">[url=http://lv.php.net/file]file[/url]</font><font color="#006600">(</font><font color="#CC0000">'dati.txt'</font><font color="#006600">); </font><font color="#0000CC">$atbilde</font><font color="#006600">=array(); foreach(</font><font color="#0000CC">$dati </font><font color="#006600">as </font><font color="#0000CC">$line</font><font color="#006600">) { if (</font><font color="#0000CC">[url=http://lv.php.net/substr_count]substr_count[/url]</font><font color="#006600">(</font><font color="#CC0000">'abols||'</font><font color="#006600">,</font><font color="#0000CC">$line</font><font color="#006600">)) {</font><font color="#0000CC">$atbilde</font><font color="#006600">[]=</font><font color="#0000CC">$line</font><font color="#006600">;} } </font><font color="#0000CC">?></font> </font> </code> ? Link to comment Share on other sites More sharing options...
jannis Posted May 24, 2003 Report Share Posted May 24, 2003 ieteikums MM-Y: iemaacies vispirms kaadu beisiku vai paskaalu ar ciklu un nosaciijumu izmantoshanu un tad kjeries klaat php! Link to comment Share on other sites More sharing options...
Recommended Posts