$tid = $_GET['tid'];
require_once $_SERVER['DOCUMENT_ROOT'] . '/common/class/class.thread.php';
$thread = new getThread;
$getThread = $thread->get_content($tid);
require_once $_SERVER['DOCUMENT_ROOT'] . '/common/class/class.thread.php';
$thread = new getThread;
$getThread = $thread->get_content($tid);
$attachmentTable = substr($tid, -1);
$tdatabase = new threadDatabase();
$tdatabase->query('SELECT * FROM mycms_forum_attachment_' . $attachmentTable . ' WHERE tid = :tid ORDER BY aid DESC');
$tdatabase->bind(':tid', $tid);
$attachmentContainer = $tdatabase->resultset();
print_r($attachmentContainer);
//following is content , it pull from db($getThread)
//main content start
[attach]42[/attach]
[align=left][attach]53[/attach][/align]
content bla bla bla content bla bla bla
[align=left][attach]52[/attach][/align]
content bla bla bla
content bla bla bla
//main content end
//following is attachment file
[0] => Array ( [aid] => 53 [tid] => 32 [pid] => 32 [uid] => 1 [filesize] => 152633 [attachment] => 201305/22/142619h42az34077hhra0p.jpg [width] => 1080 )
[1] => Array ( [aid] => 52 [tid] => 32 [pid] => 32 [uid] => 1 [filesize] => 89015 [attachment] => 201305/22/142618wx3njhgf3n883zxr.jpg [width] => 1080 )
preg_replace を使用して [attach]53[/attach] を
src は [attach]53[/attach] で幅もあるため、aid=53 の配列から取得します
$attachmentContainer[$1]['attachment'] が 0 で始まり、53 が存在しないため、エラーが発生し、この方法で行うのは間違っていることがわかっています。
$threadContainer = preg_replace('/\[attach\](.*?)\[\/attach\]/i', '<img src="' . $attachmentContainer[$1]['attachment'] . '" width="' . $attachment[$1]['width'] . '" />', $getThread['message']);
私の質問: javascript または php の方が良いですか? すべての [attach][/attach] を db の正しい src と width ストアで preg_replace するにはどうすればよいですか?
コンテンツを確認してください。改行のためにこれらの「スペース」を処理するにはどうすればよいですか?
私はディスカズを引っ張ろうとしています!db から直接 x3.0 スレッド コンテンツ。
教えてくれてありがとう!