PHP用自定义字符串替换bbcode

时间:2013-07-10 17:02:18

标签: php bbcode

我有这种情况

<?php
$string = "Hello, how are you, have a good day. [pictureblock]78[/pictureblock] Some other text.";
?>

我需要替换这个:[pictureblock] ID [/ pictureblock]

用这个:

$show div = '<div class="pictures">
<a href="img/sml/pic_one.jpg"><img class="imagethumb" src="img/sml/sml_pic_one.jpg"></img></a><a href="img/sml/pic_two.jpg"><img class="imagethumb" src="img/sml/sml_pic_two.jpg"></img></a>
</div>';

我需要从[pictureblock] THISID [/ picureblock]获取ID文本文件并使用此功能:

$dat_get = substr(file_get_contents("THISID.txt"),0,100000000000);

但我需要第二次替换,$ dat_get输出:

[d]pic_one[/d][d][/pic_two]

需要转换为:

$show div = '<div class="pictures">
<a href="img/sml/pic_one.jpg"><img class="imagethumb" src="img/sml/sml_pic_one.jpg"></img></a><a href="img/sml/pic_two.jpg"><img class="imagethumb" src="img/sml/sml_pic_two.jpg"></img></a>
</div>';

0 个答案:

没有答案