You are here

public function FullCalendar::arrayRecursiveDiff in FullCalendar 8.5

Same name and namespace in other branches
  1. 8.2 src/Plugin/fullcalendar/type/FullCalendar.php \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar::arrayRecursiveDiff()
  2. 8.4 src/Plugin/fullcalendar/type/FullCalendar.php \Drupal\fullcalendar\Plugin\fullcalendar\type\FullCalendar::arrayRecursiveDiff()

Check nested arrays for differences.

Parameters

array $array1: The original array to check against.

array $array2: The array to check for in the original one.

Return value

array Elements in $array1 that are different in $array2.

1 call to FullCalendar::arrayRecursiveDiff()
FullCalendar::filterSettings in src/Plugin/fullcalendar/type/FullCalendar.php
Check for differences in default settings for this view.

File

src/Plugin/fullcalendar/type/FullCalendar.php, line 1112

Class

FullCalendar
Plugin annotation @FullcalendarOption( id = "fullcalendar", module = "fullcalendar", js = TRUE, weight = "-20" )

Namespace

Drupal\fullcalendar\Plugin\fullcalendar\type

Code

public function arrayRecursiveDiff($array1, $array2) {
  $aReturn = [];
  foreach ($array1 as $mKey => $mValue) {
    if (array_key_exists($mKey, $array2)) {
      if (is_array($mValue)) {
        $aRecursiveDiff = $this
          ->arrayRecursiveDiff($mValue, $array2[$mKey]);
        if (count($aRecursiveDiff)) {
          $aReturn[$mKey] = $aRecursiveDiff;
        }
      }
      else {
        if ($mValue != $array2[$mKey]) {
          $aReturn[$mKey] = $mValue;
        }
      }
    }
    else {
      $aReturn[$mKey] = $mValue;
    }
  }
  return $aReturn;
}