| 
									
										
										
										
											2021-12-03 11:59:22 +01:00
										 |  |  | replace {#language.modifier.replace} | 
					
						
							|  |  |  | ======= | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | A simple search and replace on a variable. This is equivalent to the | 
					
						
							| 
									
										
										
										
											2023-02-03 17:54:00 +01:00
										 |  |  | PHP\'s [`str_replace()`](https://www.php.net/str_replace) function. | 
					
						
							| 
									
										
										
										
											2021-12-03 11:59:22 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Parameter Position    Type    Required   Default  Description | 
					
						
							|  |  |  |   -------------------- -------- ---------- --------- --------------------------------------------- | 
					
						
							|  |  |  |            1            string     Yes       *n/a*   This is the string of text to be replaced. | 
					
						
							|  |  |  |            2            string     Yes       *n/a*   This is the string of text to replace with. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $smarty->assign('articleTitle', "Child's Stool Great for Use in Garden."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ?> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Where template is: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     {$articleTitle} | 
					
						
							|  |  |  |     {$articleTitle|replace:'Garden':'Vineyard'} | 
					
						
							|  |  |  |     {$articleTitle|replace:' ':'   '} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Will output: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Child's Stool Great for Use in Garden. | 
					
						
							|  |  |  |     Child's Stool Great for Use in Vineyard. | 
					
						
							|  |  |  |     Child's   Stool   Great   for   Use   in   Garden. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | See also [`regex_replace`](#language.modifier.regex.replace) and | 
					
						
							|  |  |  | [`escape`](#language.modifier.escape). |