blondine Posted May 26, 2010 Report Share Posted May 26, 2010 (edited) ja failaa tesksts satur jaunas rindas bez html tagiem(cik saprotu fputs saglabaa ar visiem enter), tad kaa sis rindas izvadit browseri.. fpassthru izvada vienaa rindaa.. Edited May 26, 2010 by blondine Quote Link to comment Share on other sites More sharing options...
mefisto Posted May 26, 2010 Report Share Posted May 26, 2010 Izmantojot <pre> tagu ?! Problēmas, kurām tu meklē risinājumus, nesakrīt ar tava publiskotā koda sarežģītību. Quote Link to comment Share on other sites More sharing options...
blondine Posted May 26, 2010 Author Report Share Posted May 26, 2010 (edited) thx - ar kko jasak un kko nezinat ir tikai cilveciski. <pre> tomer nav tas ko mekleeju.. Edited May 26, 2010 by blondine Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 26, 2010 Report Share Posted May 26, 2010 http://uk3.php.net/nl2br Quote Link to comment Share on other sites More sharing options...
emsy Posted May 26, 2010 Report Share Posted May 26, 2010 wordwarp?? nl2br?? Quote Link to comment Share on other sites More sharing options...
blondine Posted May 26, 2010 Author Report Share Posted May 26, 2010 thx while (!feof($ar)) { $line=fgets($ar); $linenew=nl2br($line); echo $linenew; } fclose($ar); Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 26, 2010 Report Share Posted May 26, 2010 Ja viss ko tev vajag ir izvadiit faila saturu, tad iespeejams vari izmantot file_get_contents: $c = file_get_contents('/path/to/file'); $c = nl2br($c); echo $c; Quote Link to comment Share on other sites More sharing options...
emsy Posted May 26, 2010 Report Share Posted May 26, 2010 vēl īsāks: print nl2br(implode(file("/path/to/file"))); Quote Link to comment Share on other sites More sharing options...
briedis Posted May 26, 2010 Report Share Posted May 26, 2010 (edited) vēl īsāks: print nl2br(implode(file("/path/to/file"))); Šeit pierādās, ka ne vienmēr īsāk ir labāk. Tavs ieteiktais variants ir mēreni stulbs, jo tu vispirms liec php nolasīt faila saturu, ievietot to masīvā sadalot pa rindiņām, tad atkal apvienot visu vienā virknē, un tikai tad pielietot nl2br funkciju... Loģiskākais variants ir darīt kā jau rATRIJS minēja... Edited May 26, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 26, 2010 Report Share Posted May 26, 2010 +1 briedis Tik pieminēšu, ka manu variantu nevajadzētu lietot ja fails ir milzīgs + vajag veikt kaut kāda veida parsēšanu katrai rindai. Tad lasīšana pa rindiņai būtu labāka... Quote Link to comment Share on other sites More sharing options...
briedis Posted May 26, 2010 Report Share Posted May 26, 2010 +1 briedis Tik pieminēšu, ka manu variantu nevajadzētu lietot ja fails ir milzīgs + vajag veikt kaut kāda veida parsēšanu katrai rindai. Tad lasīšana pa rindiņai būtu labāka... /offtopic on +1 briedis noderētu, tad ātrāk varētu pabeigt kvalifikācijas darbu :p (Pirmdien jānoliek uz galda, PPS šovakar pabeigšu) /offtopic off Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 26, 2010 Report Share Posted May 26, 2010 <offtopic> Vēl viens kvalifikācijas darbs? :D WTF? Katru gadu pa vienam tagad? :D (nākamgad tak bakalaurs). Diezgan traki. + traki, ka 2 dienās PPA & testēšanas/user dokumentācija :D ceru, ka kods ir :D </offtopic> P.S. palīdzībai dodu +1*$n briedis - $n ļauju tev definēt ^_^ Quote Link to comment Share on other sites More sharing options...
emsy Posted May 27, 2010 Report Share Posted May 27, 2010 Izdomāju :) <?php $file = file("/path/to/file"); foreach($file as $row) { $row."<br />"; } ?> Quote Link to comment Share on other sites More sharing options...
briedis Posted May 27, 2010 Report Share Posted May 27, 2010 Izdomāju :) <?php $file = file("/path/to/file"); foreach($file as $row) { $row."<br />"; } ?> Emsy, nu ar ko šis variatns atsķiras no tava iepriekšējā? Šis pat ir švakāks :) īsāk sanāktu šitā: $result = implode("<br />", file("fails.txt")); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.