我有这个多维数组:
Array
(
[userId] => 35
[fieldId] => Array
(
[0] => 1
[1] => 2
[2] => 3
[4] => 4
)
[educationTitle] => Array
(
[0] => School1
[1] => School2
[2] => 3
[4] =>
)
[educationDegree] => Array
(
[0] => Degree1
[1] => Degree2
[2] => 3
[4] =>
)
[startDate] => Array
(
[0] => 2013-03-01
[1] => 2013-03-03
[2] => 1970-01-01
)
[endDate] => Array
(
[0] => 2013-03-02
[1] => 2013-03-04
[2] => 1970-01-01
)
[educationDescription] => Array
(
[0] => Description1
[1] => Description2
[2] =>
)
)
我有一个名为 id 的数组matches
:
[matches] => Array
(
[0] => 1
[1] => 2
)
我需要将主数组分成两个:
$eduAdd = array()
$eduUpdate = array()
$eduAdd
将包含不匹配的 fieldId,$eduUpdate
并将包含匹配的 fieldId。
$eduAdd
看起来像这样:
Array
(
[userId] => 35
[fieldId] => Array
(
[2] => 3
[4] => 4
)
[educationTitle] => Array
(
[2] => 3
[4] =>
)
[educationDegree] => Array
(
[2] => 3
[4] =>
)
[startDate] => Array
(
[2] => 1970-01-01
)
[endDate] => Array
(
[2] => 1970-01-01
)
[educationDescription] => Array
(
[2] =>
)
)
我试过这个,但发现in_array
不适用于多维数组:
foreach($filteredSubmittedData as $filteredUpdates){
if(in_array($filteredUpdates['fieldId'], $matches)){
echo "yup";
}
}
我怎样才能做到这一点?