我正在使用以下代码:
foreach ($_POST as $key => $value) {
(preg_match("/^._box_(\d+)_5$/", $key, $matches));
//$prodid[] = $matches[1];
$firephp->log($matches, 'matches');
};
此代码正在处理从上一页 $_POSTed 的以下信息:
array(
['clin'] =>
['clinmail'] =>
['quest_3'] =>
['quest_7'] =>
['quest_8'] =>
['quest_9'] =>
['quest_10'] =>
['quest_15'] =>
['quest_16'] =>
['hosp'] => 8
['user'] => 16
['a_box_15_5'] => 2
['a_box_16_5'] => 2
['b_box_1_5'] => '$0.00'
['b_box_29_5'] => 1
)
问题是我得到以下结果:
matches: array()
matches: array()
matches: array()
matches: array()
matches: array()
matches: array()
matches: array()
matches: array()
matches: array()
matches: array()
matches: array()
matches: array('0'=>'a_box_15_5', '1'=>'15')
matches: array('0'=>'a_box_16_5', '1'=>'16')
matches: array('0'=>'b_box_1_5', '1'=>'1')
matches: array('0'=>'b_box_29_5', '1'=>'29')
我不希望它匹配前 11 个位置。我只想要实际匹配我正在寻找的结果,在这种情况下,最后四个 $_POST 不是 preg_match 应该做的吗?我怎样才能将它限制在比赛中?