fork download
  1. <?php
  2. $string='[li id="1"]text1[div]text2[/div][/li]';
  3. $pattern=':\[([^\]]+)\]:';
  4. echo preg_replace($pattern,"<$1>",$string);
  5.  
  6. // your code goes here
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
<li id="1">text1<div>text2</div></li>