webdogjcn Posted June 6, 2006 Share Posted June 6, 2006 okay so I have a fast reply form and a link that lets you insert emoticons. well i have everything working where a pop-up appears and the emoticon text is displayed like ";sad;" (replace ; with :) and now I want to convert all instances (when they submit the form) of ;sad; with <image src="sad.gif" alt=sad> Quote Link to comment https://forums.phpfreaks.com/topic/11365-converting-form-data/ Share on other sites More sharing options...
markduce Posted June 6, 2006 Share Posted June 6, 2006 OK, just use the str_replace function (string replace) as follows:<?$message=$_POST['message']; // OR WHATEVER YOUR MESSAGE VARIABLE IS$message=str_replace(';sad;', '<image src="sad.gif" alt=sad>', $message);?>Hope that helpsMark Quote Link to comment https://forums.phpfreaks.com/topic/11365-converting-form-data/#findComment-42622 Share on other sites More sharing options...
webdogjcn Posted June 7, 2006 Author Share Posted June 7, 2006 Okay, thanks for the help. But one more question, what about convereting user entered line breaks to <br>?Because when someone presses enter in a textarea it will just recognize it as a space not a line break. Quote Link to comment https://forums.phpfreaks.com/topic/11365-converting-form-data/#findComment-42856 Share on other sites More sharing options...
kenrbnsn Posted June 7, 2006 Share Posted June 7, 2006 When you want to display the text use the nl2br() function which will insert "<br ?>" tags before each newline character.[code]<?php echo nl2br($message) ?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/11365-converting-form-data/#findComment-42874 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.