以下代码没有给我预期的结果。
if (isset($newpost['message']))
{
$matches = array();
preg_match_all("~\[QUOTE\=.*;(\d+)\]~isU", $newpost['message'], $matches);
var_dump($matches);
die();
}
$matches 应该包含匹配的结果。但是,$matches 总是等于整个 $newpost 数组(不仅仅是消息部分)。上面的结果可能如下所示:
array(22) { ["message"]=> string(17) "testing123..." ["title"]=> &string(0) "" ["iconid"]=> &int(0) ["parseurl"]=> bool(true) ["signature"]=> &int(1) ["preview"]=> &string(0) "" ["disablesmilies"]=> &int(0) ["rating"]=> &int(0) ["username"]=> &string(0) "" ["folderid"]=> &int(0) ["quickreply"]=> &int(0) ["poststarttime"]=> &int(1368357609) ["posthash"]=> &string(32) "4d513f4123f780c6b10739e3a5dd0fb6" ["humanverify"]=> &array(0) { } ["stickunstick"]=> &int(0) ["openclose"]=> &int(0) ["ajaxqrfailed"]=> int(0) ["emailupdate"]=> &int(9999) ["enablesmilies"]=> int(1) ["podcastsize"]=> int(0) ["visible"]=> int(1) ["postid"]=> int(1771567) }
我认为这是因为 $newpost 可能会作为参考来处理。不确定,虽然...