HoTDaWg Posted August 14, 2009 Share Posted August 14, 2009 hey guys, so in my textarea im using wrap="virtual" and it gets the job done. The problem is that if a user were to type in a long string of A's or paste a link for example, this ruins my design when it shows up. Currently I am utilizing the word wrap function to place a <br> every 50 characters (which is how much, approximately width-wise, my textarea can hold per line); the problem is that assuming a user were to type his comment spread out on multiple lines, it would create a <br> for no reason just because its the 50th character, this is effecting my emoticon system. here is a copy of the code: <?php $codes = array(''=>'<img src="includes/images/emoticon_tongue.png">', ''=>'<img src="includes/images/emoticon_unhappy.png">', ''=>'<img src="includes/images/emoticon_wink.png">', 'XD'=>'<img src="includes/images/emoticon_evilgrin.png">', ''=>'<img src="includes/images/emoticon_happy.png">', ''=>'<img src="includes/images/emoticon_smile.png">', ''=>'<img src="includes/images/emoticon_surprised.png">'); while($row = mysqli_fetch_array($result)){ $newnewcomment = $row['comment_comment']; $dacomment = stripslashes($newnewcomment); $newnewnewcomment = wordwrap($dacomment,'50','<br>',true); $finalcomment = str_replace(array_keys($codes),array_values($codes),$newnewnewcomment); $comments .= '<hr><b>'.$row['comment_name'].'</b> Wrote on ' . date('l, F jS, Y g:i A',$row['comment_date']).':<br><br>' . $finalcomment . '<br>'; } ?> even if i placed the line that substitutes emoticons in front of the line that wraps the word, the wordwrap would include the <img src> tags and consider them as characters, it would place breaks within the image tags... any ideas guys?:S thanks, HoTDawg Quote Link to comment Share on other sites More sharing options...
smerny Posted August 14, 2009 Share Posted August 14, 2009 try using the nl2br() function instead of the wordwrap... i'm not sure if thats what you're looking for so check it and see if it is Quote Link to comment Share on other sites More sharing options...
HoTDaWg Posted August 14, 2009 Author Share Posted August 14, 2009 nl2br does not work for me because assuming the user was to hold down the "a" key, a series of A's would appear and there would be no line breaks at all, this series of A's would need seperation as it could potentially ruin my layout. Thats why i have been using wordwrap, because it wraps long series of texts anyways, whether they have a /n or not right now im thinking to create a custom function, that based on if the string has spaces it would put in a <br> any other ideas? Quote Link to comment Share on other sites More sharing options...
smerny Posted August 14, 2009 Share Posted August 14, 2009 you'll find this helpful, i believe http://www.codingforums.com/archive/index.php/t-168890.html Quote Link to comment Share on other sites More sharing options...
HoTDaWg Posted August 14, 2009 Author Share Posted August 14, 2009 yes thank you so much... you've saved me from a whole lotta headaches! 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.