title: Replace multiple words in string with PHP
body: <p>I need a systematic way of replacing each word in a string separately by providing my own input for each word. I want to do this on the command line.</p>
  
  <p>So the program reads in a string, and asks me what I want to replace the first word with, and then the second word, and then the third word, and so on, until all words have been processed. </p>
  
  <p>The sentences in the string have to remain well-formed, so the algorithm should take care not to mess up punctuation and spacing.</p>
  
  <p>Is there a proper way to do this?</p>