graham23s Posted June 19, 2010 Share Posted June 19, 2010 Hi Guys, I'm using the simple php dom class to parse an html page, i'm using the ->plaintext; to just retrieve the words rather than the html, then i'm trying to wordwrap: <?php $prodID = $_GET['productID']; $q = mysql_query("SELECT * FROM `dig_products` WHERE `id`='$prodID'"); $a = mysql_fetch_array($q); $s = $a['product_original_url']; $html = file_get_html($s)->plaintext; echo "<center><textarea rows='50' cols='50'>" . wordwrap($html, 10, "\n", true) . "</textarea></center>"; //echo "<pre>$html</pre>"; ?> the problem is it's not wordwrapping the text no matter what number i set it to, i'm stumped thanks for nay help guys Graham Quote Link to comment Share on other sites More sharing options...
cags Posted June 19, 2010 Share Posted June 19, 2010 So you are clicking view source and there are no line breaks? If you aren't clicking view source then you won't see any line breaks since \n characters are ignored within HTML documents. You would need to use '<br/>\n' as your 3rd parameter. Quote Link to comment Share on other sites More sharing options...
theverychap Posted June 19, 2010 Share Posted June 19, 2010 or wrap nl2br around the wordwrap function: nl2br(wordwrap($html, 10, "\n", true)); Quote Link to comment Share on other sites More sharing options...
graham23s Posted June 19, 2010 Author Share Posted June 19, 2010 Thanks a lot guys Graham 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.