title: Golang replace array elements by array elements in string
body: <p>In PHP we can do something like : </p>
  
  <pre><code>$result = str_replace($str,$array1,$array2);
  </code></pre>
  
  <p>Where $array1 and $array2 are array of elements, this makes php replace all array1 elements by array2 elements.
  Is there any equivalent to this using the Golang? I have tried the same php approach but it did not work :</p>
  
  <pre><code>str := "hello world"
  array1 :=  []string {"hello","world"}
  array2 :=  []string {"foo","bar"}
  r := strings.NewReplacer(array1,array2)
  str = r.Replace(str)
  </code></pre>
  
  <p>I know I can do something like : </p>
  
  <pre><code>str := "hello world"
  array1 :=  []string {"hello","world"}
  array2 :=  []string {"foo","bar"}
  r := strings.NewReplacer("hello","foo","world","bar")
  str = r.Replace(str)
  </code></pre>
  
  <p>That would work but I need to use arrays directly because the arrays of replacements will be created dynamically.</p>