数据结构;[data:private] => Array
(
[id] => Array
(
[0] => 269061
[1] => 269376
) [issuetime] => 2011年09月
[PpjID] => 14262
[corpid] => Array
(
[0] => 379984,269061
[1] => 233241,269376
[2] => 690894,270702
[3] => 694397,278090
) )要的结果;
array
(
[0] => 379984
[1] => 233241
)
(
'id' => Array
(
0 => '269061',
1 => '269376'
)
,
'issuetime' => '2011年09月',
'PpjID' => '14262',
'corpid' => Array
(
0 => '379984,269061',
1 => '233241,269376',
2 => '690894,270702',
3 => '694397,278090'
)
);$ar = array();
foreach($data['corpid'] as $v) {
$tmp = explode(',', $v);
$ar[$tmp[1]] = $tmp[0];
}
$result = array();
foreach($data['id'] as $v) $result[] = $ar[$v];
print_r($result);
$array = array(
'id' => array(269061,269376),
'corpid' => array('379984,269061','233241,269376', '690894,270702', '694397,278090')
);
$pattern = '(' . implode('|', $array['id']) . ')';
foreach($array['corpid'] as $row) {
if(preg_match("/(\d+),$pattern/", $row, $matches)) {
echo $matches[1] . '<br/>';
}
}
/**
输出结果:
379984
233241
*/