<?php
  $arr1 = array("%imie1%", "%imie2%");
  $arr2 = array("Ala", "Ola");
  $arr3 = array("%imie1%", "ma", "kota.");

  $str = str_replace($arr1, $arr2, "%imie1% ma kota. %imie2% ma psa.");
  echo "$str<br>";

  $str = str_replace($arr1, "Magda", "%imie1% ma kota. %imie2% ma psa.");
  echo "$str<br>";

  $str = str_replace("%imie1%", "Ela", $arr3);
  foreach($str as $word) echo("$word ");
?>
