私はこの多次元配列を持っています:
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
)
メイン配列を 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";
}
}
これどうやってするの?