Advertisement
jaideejung007

PHP Array Replace Function

Aug 7th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. <?php
  2. /**
  3.  *
  4.  * PHP Array Replace Function
  5.  *
  6.  * @author jaideejung007 http://www.discuzthai.com
  7.  * @copyright 2016 DiscuzThai
  8.  * @license https://creativecommons.org/licenses/by/3.0/th/
  9.  *
  10.  * @version 0.1.1
  11.  */
  12.  
  13. $jjWord = "My name is <strong>{string1}</strong>  <strong>{string2}</strong>, ID <strong>{string3}</strong>";
  14. $jjFind1 = "Anusuk";
  15. $jjFind2 = "Sangubon";
  16. $jjFind3 = "jaideejung007";
  17.  
  18. $jjArrayFind = array(
  19.     "{string1}",
  20.     "{string2}",
  21.     "{string3}"
  22. );
  23.  
  24. $jjArrayReplace = array(
  25.     $jjFind1,
  26.     $jjFind2,
  27.     $jjFind3
  28. );
  29. echo addslashes(str_replace($jjArrayFind,$jjArrayReplace,$jjWord));
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement