Created
          March 1, 2018 16:04 
        
      - 
      
 - 
        
Save TakesTheBiscuit/f48a7a2f85f70aedf18c066c2fcabf97 to your computer and use it in GitHub Desktop.  
    string replacement 
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| $stringage = [ | |
| 'order_id'=>'5678', | |
| 'name'=>'NO ONE cares' | |
| ]; | |
| echo replace_with_personal_data('There was a problem on order #[order_id] please phone [name]', $stringage); | |
| function replace_with_personal_data($string, $strings) { | |
| $output = $string; | |
| foreach ($strings as $injectable_key => $injectable_string) { | |
| $output = str_replace('['.$injectable_key.']', $injectable_string, $output); | |
| } | |
| return $output; | |
| } | |
| ?> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment