I have the following problem. I want to create a preg_replace() function to replace, for example:
[div_row_392]...text...[/div]
to
<div class="row" id="392">...text...</div>
I have the following problem. I want to create a preg_replace() function to replace, for example:
[div_row_392]...text...[/div]
to
<div class="row" id="392">...text...</div>
This may work for you:
$html = "[div_row_392]...text...[/div]";
$html = preg_replace('%\[(.*?)_(.*?)_(.*?)\](.*?)\[/(.*?)\]%sim', '<$1 class="$2" id="$3">$4</$5>', $html);
echo $html;
//<div class="row" id="392">...text...</div>