protected function ParagraphsPackTestCase::array_diff_assoc_deep in Paragraphs pack 7
Helper function for mulitdimensional arrays deep comparison
Parameters
array $array1: First array for comparison.
array $array2: Second array for comparison.
Return value
array A hierarchical difference between arrays.
5 calls to ParagraphsPackTestCase::array_diff_assoc_deep()
- ParagraphsPackTestCase::testParagraphsPackFieldBodyInstanceCreation in tests/
paragraphs_pack.test - Test function for field body instance creation.
- ParagraphsPackTestCase::testParagraphsPackFieldFileInstanceCreation in tests/
paragraphs_pack.test - Test function for field file instance creation.
- ParagraphsPackTestCase::testParagraphsPackFieldItemsInstanceCreation in tests/
paragraphs_pack.test - Test function for field items instance creation.
- ParagraphsPackTestCase::testParagraphsPackFieldTitleInstanceCreation in tests/
paragraphs_pack.test - Test function for field title instance creation.
- ParagraphsPackTestCase::testParagraphsPackFieldViewModeInstanceCreation in tests/
paragraphs_pack.test - Test function for field view mode instance creation.
File
- tests/
paragraphs_pack.test, line 416 - Paragraphs pack primary module's tests.
Class
- ParagraphsPackTestCase
- Test Case for Paragraphs pack primary module.
Code
protected function array_diff_assoc_deep($array1, $array2) {
$difference = array();
foreach ($array1 as $key => $value) {
if (is_array($value)) {
if (!isset($array2[$key])) {
$difference[$key] = $value;
}
elseif (!is_array($array2[$key])) {
$difference[$key] = $value;
}
else {
$new_diff = $this
->array_diff_assoc_deep($value, $array2[$key]);
if ($new_diff != FALSE) {
$difference[$key] = $new_diff;
}
}
}
elseif (!isset($array2[$key]) || $array2[$key] != $value) {
$difference[$key] = $value;
}
}
return $difference;
}