BenPac Posted May 5, 2007 Share Posted May 5, 2007 Just started to learn php and would be grateful for some help. My problem is that I want to search a string coming from a textarea, but the substring I want to identify is broken up by newlines and is not returned. How do I solve this. For example: Input in the textarea: MyNameIsJohnMc LoudAndIam3040 How do I identify Mcloud or basically producing the string: MyNameIsJohnMcLoudAndIam3040 Link to comment https://forums.phpfreaks.com/topic/50116-solved-how-do-i-search-for-a-string-broken-up-by-new-lines/ Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 try this <form method="post" action=""> <textarea name="textarea">MyNameIsJohnMc LoudAndIam3040</textarea> <input name="submit" type="submit" value="submit" /> </form> <?php if( isset($_POST['submit']) ) { //Leaves a space //echo preg_replace('#\n#sim', '', $_POST['textarea']); //clears the space echo preg_replace('#\s?\n\s?#sim', '', $_POST['textarea']); } ?> Link to comment https://forums.phpfreaks.com/topic/50116-solved-how-do-i-search-for-a-string-broken-up-by-new-lines/#findComment-246070 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.