wata Posted December 4, 2006 Share Posted December 4, 2006 hi ive done this code but its not printing any ideas why not or have i missed something out here is the code anyway<?php$page=file_get_contents(std_info.txt);$lines=file(std_info.txt)$n=0;print "all the names $page";?> Quote Link to comment Share on other sites More sharing options...
trq Posted December 4, 2006 Share Posted December 4, 2006 I'll assume [i]std_info.txt[/i] is a string, not a constant. Your code should be generating errors. Try...[code]<?php $page=file_get_contents("std_info.txt"); print "all the names $page";?>[/code] Quote Link to comment Share on other sites More sharing options...
jsladek Posted December 5, 2006 Share Posted December 5, 2006 Is it printing anything?Should it be... print ("all the names $page");-John Quote Link to comment Share on other sites More sharing options...
wata Posted December 5, 2006 Author Share Posted December 5, 2006 thank you now it is printing but how can i add a <br> after each name so its in a list? Quote Link to comment Share on other sites More sharing options...
papaface Posted December 5, 2006 Share Posted December 5, 2006 [code]print "<pre>";print_r ("all the names $page");print "</pre>";[/code]I believe that will do what you want. Quote Link to comment Share on other sites More sharing options...
wata Posted December 5, 2006 Author Share Posted December 5, 2006 what does the <pre> mean? Quote Link to comment Share on other sites More sharing options...
trq Posted December 5, 2006 Share Posted December 5, 2006 Assuming you meant to ask how to add a newline you'll want to use file() not file_get_contents(). eg;[code]<?php $lines = file("std_info.txt"); foreach ($lines as $line) { print "all the names $line</br >"; }?>[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted December 5, 2006 Share Posted December 5, 2006 [quote author=wata link=topic=117361.msg478805#msg478805 date=1165277295]what does the <pre> mean?[/quote]What does the what mean? What is wrong with your keyboard? Quote Link to comment Share on other sites More sharing options...
wata Posted December 5, 2006 Author Share Posted December 5, 2006 sorry keyboard fine finger slipt i meant to say what does <pre> mean Quote Link to comment Share on other sites More sharing options...
wata Posted December 5, 2006 Author Share Posted December 5, 2006 when i put angle bracket it spells "MEAN" so i meant again angle bracket pre close angle bracket Quote Link to comment Share on other sites More sharing options...
papaface Posted December 5, 2006 Share Posted December 5, 2006 [code]<?php $lines = file("std_info.txt"); foreach ($lines as $line) { print "<pre>"; print_r ("all the names $line \n"); print "</pre>"; }?>[/code]^^ altered a bit. Quote Link to comment Share on other sites More sharing options...
trq Posted December 5, 2006 Share Posted December 5, 2006 Its html. You really ought learn it before php. Quote Link to comment Share on other sites More sharing options...
wata Posted December 5, 2006 Author Share Posted December 5, 2006 thank you all is working :) 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.