我正在编写一个简单的代码,但无法准确找到我出错的地方。
$data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget tellus cursus, ultrices justo at, ultricies libero. Vivamus consequat ante vel nunc dapibus, non tempus elit vehicula. Nulla facilisi. Proin leo urna, congue eu justo eget, viverra mattis lacus.
#otwquote";
preg_match_all('/\s#otw[0-9a-z]+\b/i', $data, $matches);
$matchtag = str_replace("#otw", "", strtolower($matches[0][0]));
echo $matchtag;
$formats = array("status", "aside", "link", "gallery", "image", "audio", "video", "quote", "chat", "standard");
$backhash ="standard";
// here $matchtag = "quote"
if ( in_array ( $matchtag , $formats ) ) {
echo $matchtag;
} else {
echo $backhash;
}
现在当我使用
if ( in_array ( "quote" , $formats ) )
它工作正常。但是使用变量 $matchtag 它返回错误。请帮忙。谢谢
注意:我发现如果我把它放在$matchtag = "quote";
in_array 之前它工作正常。$matchtag
那么变量的格式有什么问题吗?