0
我正在使用我的博客的联系页面插件。使用此代码的短代码是 [my-shortcode]
。 是否有反正只过滤来自内容的简码。 如: Test post [my-shortcode] Demo widget
。在这里我需要过滤只有shortcode.Thank你仅从帖子中过滤短代码
我正在使用我的博客的联系页面插件。使用此代码的短代码是 [my-shortcode]
。 是否有反正只过滤来自内容的简码。 如: Test post [my-shortcode] Demo widget
。在这里我需要过滤只有shortcode.Thank你仅从帖子中过滤短代码
您可以使用正则表达式来得到一个字符串中括号内的值,像这样。
if(preg_match_all('/\[(.*?)\]/',$_POST['my_key'],$matches))
{
foreach($matches as $match)
{
if($match[1] == 'my-short-code')
{
//Do whetever
break 2;
}
}
}
注:match[1]
可能match[0]
非常感谢你 – 2010-09-17 11:23:28
看看在这个问题的答案,问勉强几个小时前http://stackoverflow.com/questions/3734519/seach-inside-a -string也提取信息[和] – 2010-09-17 11:10:03