Consider the following input as an example:
[Ami]Song lyrics herp derp [F]song lyrics continue
[C7/B]Song lyrics continue on another [F#mi7/D]line
I need to parse the above and echo it as the following:
<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
So basically, I need to:
1) change [
to <div class="chord">
,
2) then append the content of the brackets,
3) then change ]
to </div>
.
... using PHP 5.3+.
This will work.
$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
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With