fork download
  1. <?php
  2.  
  3. $myStr ="<font face=\"#3#\" size=\"6\">TEST #114# another occurence</font>";
  4.  
  5. $fontList = array(
  6. 0 => "ubuntumono",
  7. 1 => "opensans",
  8. 2 => "opensanscondensed",
  9. 3 => 'opensanslight',
  10. 4 => 'exo2',
  11. 5 => 'exo2light'
  12. );
  13.  
  14. $myStr = preg_replace_callback('/"#(\d+)#"/', function ($matches) use ($fontList) {
  15. return '"'. $fontList[$matches[1]] . '"';
  16. }, $myStr);
  17.  
  18. echo $myStr . "\n";
  19. ?>
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
<font face="opensanslight" size="6">TEST #114# another occurence</font>