| The Arcive of vBulletin Modifications Site. | |
| 
			 
			#1  
			
			
			
			
			
		 | ||||
| 
 | ||||
|  Help with preg_replace and regexp 
			
			Working on a small PHP mailer form project on Apache v1.3.36 to sent html-formatted mail. Form is POSTed with message text in a textarea named COMMENT. Some code I'm adapting uses the following to strip linefeeds and replace with html breaks: Code: $comment = preg_replace("/\n/","\n<BR>",$_POST[COMMENT]);I don't know beans about regular expressions. Can anybody help straighten this out? Or is there something else that needs to be done to have apostrophes show up correctly? | 
| 
			 
			#2  
			
			
			
			
			
		 | |||
| 
 | |||
|   
			
			Below that line add PHP Code: 
			 | 
| 
			 
			#3  
			
			
			
			
			
		 | ||||
| 
 | ||||
|   
			
			Why don't you just use the php function nl2br(); nl2br(string string) //Inserts HTML line breaks before all newlines in a string | 
| 
			 
			#4  
			
			
			
			
			
		 | ||||
| 
 | ||||
|   Quote: 
 Quote: 
 But still getting the \' , so still have to use stripslashes(). Any idea which of the two approaches is less server intensive? | 
| 
			 
			#5  
			
			
			
			
			
		 | ||||
| 
 | ||||
|   
			
			well, nl2br was made to do that and only that, so I would guess that is the best method.
		 | 
|  | 
| 
 | 
 | 
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
| 
 | |
|  More Information | |
| Template Usage: 
 Phrase Groups Available: 
 | Included Files: 
 Hooks Called: 
 |