-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