以下列输入为例: [Ami]Song lyrics herp derp [F]song lyrics continue
[C7/B]Song lyrics continue on another [F#mi7/D]line 我需要解析以上内容,并将其回应如下: <div class="chord">Ami</div>Song lyrics herp derp <div class="chord">
以下列输入为例:
[Ami]Song lyrics herp derp [F]song lyrics continue
[C7/B]Song lyrics continue on another [F#mi7/D]line
我需要解析以上内容,并将其回应如下:
<div class="chord">Ami</div>Song lyrics herp derp <div class="chord">F</div>song lyrics continue
<div class="chord">C7/B</div>Song lyrics continue on another <div class="chord">F#mi7/D</div>line
所以基本上我需要:
1)改变[到< div class =“chord”>
2)然后附加括号的内容,
3)然后更改]为< / div> ;. …使用PHP 5.3.
这将工作.
$tab = "[Ami]Song lyrics herp derp [F]song lyrics continue
[C7/B]Song lyrics continue on another [F#mi7/D]line";
echo str_replace(
array('[',']'),array('<div class="chord">','</div>'),$tab
);