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 Link to comment https://forums.phpfreaks.com/topic/205246-wordwrap-not-wrapping/ 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. Link to comment https://forums.phpfreaks.com/topic/205246-wordwrap-not-wrapping/#findComment-1074338 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)); Link to comment https://forums.phpfreaks.com/topic/205246-wordwrap-not-wrapping/#findComment-1074353 Share on other sites More sharing options...
graham23s Posted June 19, 2010 Author Share Posted June 19, 2010 Thanks a lot guys Graham Link to comment https://forums.phpfreaks.com/topic/205246-wordwrap-not-wrapping/#findComment-1074377 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.