-1
我使用preg_match_all
單引號'
在我的WordPress代碼的語法高亮和它工作PHP的preg_match獲得WordPress的語法雙引號中的字符串
preg_match_all("/'(.*?)'/",$content,$matches);
但是,當我使用雙引號"
與這個代碼,它不工作
preg_match_all('/"(.*?)"/',$content,$matches);
有沒有一種簡單的方法來修復代碼?
- 編輯 -
我使用這個代碼,使自己的WordPress的語法高亮代碼插件
function myHighlightSyntaxCode($content)
{
global $post;
$content= $post->post_content;
$content=reformatText($content);
return $content;
}
function reformatText($content){
preg_match_all("/'(.*?)'/",$content,$matches);
/*
this is the part of my code for content inside quote
*/
}
add_filter('the_content', 'myHighlightSyntaxCode');
您可以向我們展示'$ content'的例子以及您期望在'$ matches'中找到的內容嗎? – Halcyon
是的,你可以在我的博客上看到:) http://blog.imammubin.com/php-class-database-connection-construct-function-class-by-subclass/2014/02/05/ – Mubin