everisk Posted September 19, 2007 Share Posted September 19, 2007 Hello all, I need some help printing some code on the page. Originally I read HTML code from a url and I need to replace 'Beginning of Line' and 'End of Line' with line number. However, I do not know how this can be done. Any help would be really appreciated. $enews = file_get_contents("http://my.sony.co.th/newsletter/issue/issue-MySony061aug22/index_en.html"); $enews = htmlspecialchars($enews); print "<pre>$enews</pre>" Quote Link to comment Share on other sites More sharing options...
EKINdesigns Posted September 19, 2007 Share Posted September 19, 2007 Try this: <?PHP $enews = file_get_contents("http://my.sony.co.th/newsletter/issue/issue-MySony061aug22/index_en.html"); $enews = htmlspecialchars($enews); $enews_array = explode(chr(13),$enews); $line_num = 1; foreach($enews_array as $line){ echo $line_num . "" . $line; $line_num++; } ?> Quote Link to comment Share on other sites More sharing options...
everisk Posted September 20, 2007 Author Share Posted September 20, 2007 Thanks EKINdesigns. It worked, except that i have to change chr(13) to chr(10). But thanks a lot! 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.