0
preg_replace('/\[quote\=(.*?);(.*?)\](.*?)\[\/quote\]/ms', '<blockquote>Posted by: \1 at \2.<br/>\3</blockquote>', $text);

これは私が[quote=user;id]content[/quote]bbcodeを置き換えるために使用するものです。とにかく、投稿に引用が1つある場合にのみ、正常に機能します。

私が得た場合:

[quote=user1;1] [quote=user0;0]some content here[/quote]

this is my reply to user0 post[/quote]

最初の引用符のみが置き換えられ、その他は。に置き換えられません<blockquote>

どうすれば修正できますか?

4

1 に答える 1

1

テスト済み、修復済みバージョン

<?php
$out = '[quote=user1;1] [quote=user0;0]some content here[/quote]this is my reply to user0 post[/quote]';
$cnt = 1;
while($cnt != 0){
    $out = preg_replace('/\[quote\=(.*?);(.*?)\](.*?)\[\/quote\]/ms', '<blockquote>Posted by: \1 at \2.<br/>\3</blockquote>', $out, -1, $cnt);
}
echo $out;

http://codepad.org/3PoxBeQ5

于 2011-10-03T09:31:21.510 に答える