fork download
  1. <?php
  2. $stringA = 'Whatcha talkin bout Willis?';
  3. $stringB = 'aeiou';
  4.  
  5. $find = str_split($stringB);
  6. $replace = array();
  7. foreach ($find as $ltr)
  8. {
  9. $replace[] = sprintf('<span>%s</span>', $ltr);
  10. }
  11. $stringA = str_replace($find, $replace, $stringA);
  12.  
  13. var_dump($stringA);
Success #stdin #stdout 0.02s 13064KB
stdin
Standard input is empty
stdout
string(131) "Wh<span>a</span>tch<span>a</span> t<span>a</span>lk<span>i</span>n b<span>o</span><span>u</span>t W<span>i</span>ll<span>i</span>s?"