0
我试图更改模板中的多行。我使用vBulletin软件。创建多个字符串替换
这是我有:
$drcidl_inc = '<!--/CSS Stylesheet -->';
$drcidl_cr = '$vbphrase[powered_by_vbulletin]';
$drcrb_hd = '<textarea name=\"message\" id=\"{$editorid}_textarea\" rows=\"10\" cols=\"60\" style=\"width:100%; height:{$editor_height}px\" tabindex=\"1\" dir=\"$stylevar[textdirection]\"></textarea>';
$find = '<textarea name=\"message\" id=\"{$editorid}_textarea\"';
$replace = '<textarea class=\"form-control comment-form-textarea\" name=\"message\" id=\"{$editorid}_textarea\"';
if(strpos($vbulletin->templatecache['headinclude'],$drcidl_inc) !==false)$vbulletin->templatecache['headinclude'] = str_replace($drcidl_inc,fetch_template('drc_iiu_css').$drcidl_inc,$vbulletin->templatecache['headinclude']);
else $vbulletin->templatecache['headinclude'] .= fetch_template('drc_iiu_css');
$vbulletin->templatecache['showthread_quickreply'] = str_replace($find,$replace,$vbulletin->templatecache['showthread_quickreply']);
$vbulletin->templatecache['showthread_quickreply'] = str_replace($drcrb_hd,$drcrb_hd.fetch_template('drc_iiu_below_txtarea'),$vbulletin->templatecache['showthread_quickreply']);
$vbulletin->templatecache['footer'] = str_replace($drcidl_cr,$drcidl_cr.fetch_template('drc_iiu_js'),$vbulletin->templatecache['footer']);
这工作,但只有第一个showthread_quickreply str_replace函数是否正常工作。 我不确定如何解释这个问题,但是我怎样才能在一个变量上使用多个str_replace?
这是一个我试图合并:
$vbulletin->templatecache['showthread_quickreply'] = str_replace($find,$replace,$vbulletin->templatecache['showthread_quickreply']);
$vbulletin->templatecache['showthread_quickreply'] = str_replace($drcrb_hd,$drcrb_hd.fetch_template('drc_iiu_below_txtarea'),$vbulletin->templatecache['showthread_quickreply']);
,我需要另外一个添加到它还是太。
这听起来像你可能需要一个更强大的替代方法,比如'preg_replace_callback()' – Rasclatt
我琢磨出来了,我只是在最后一个块的代码中有错误的命令,翻转它们解决它。我正在替换textarea名称,用textarea类名...在另一个替换者找到它之前。 ...如果这使得大声笑 –