나는이 다차원 배열이로 다차원 배열 :분할 두 개의 새로운 배열
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] =>
)
)
을 내가 matches
라는 ID의 배열이 있습니다
[matches] => Array
(
[0] => 1
[1] => 2
)
나는 두 가지로 주요 배열을 분할해야 :
$eduAdd = array()
$eduUpdate = array()
$eduAdd
에는 일치하지 않는 fieldId의 및 $eduUpdate
에는 fieldId의이 포함됩니다.
$eduAdd
foreach($filteredSubmittedData as $filteredUpdates){
if(in_array($filteredUpdates['fieldId'], $matches)){
echo "yup";
}
}
어떻게하면 할 수
: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
다차원 배열에서 작동하지 않습니다 알아,하지만이 시도 발견?
헤이 @ 쥬이! 도와 주셔서 감사합니다. 여기에 오타가 있습니다'($ main [ 'fieldId'] $ i = $ v)''=>'내가 변경하고 실행했지만 오류가 발생했습니다 경고 : 잘못된 인수가 foreach()'에 제공되었습니다. 'foreach ($ arr $ i => $ v) {'를 참조하고 있습니다. 그것은 정말로 늦었 어 (2am) 여기에서 I 'll는 이것을 또 한번 본다. 감사! –
@relentless, yup, 당신은 오타가 맞았습니다. 그리고 메인 배열의 첫 번째 요소가 배열이 아니므로'continue '를 추가하여 건너 뜁니다. 둘 다 고정.이제는 작동 할 것입니다. – Shoe
잘 했어! 도와 주셔서 감사합니다! –