arrayDiffAssocRecursive() публичный статический Метод

This method is a recursive version of php array_diff_assoc()
public static arrayDiffAssocRecursive ( array $array1, array $array2 ) : array
$array1 array Source array
$array2 array Reduce source array by this array
Результат array Source array reduced by keys also present in second array
Пример #1
0
 /**
  * @test
  */
 public function arrayDiffAssocRecursiveHandlesMixedArrays()
 {
     $array1 = array('key1' => array('key11' => 'value11', 'key12' => 'value12'), 'key2' => 'value2', 'key3' => 'value3');
     $array2 = array('key1' => 'value1', 'key2' => array('key21' => 'value21'));
     $expectedResult = array('key3' => 'value3');
     $actualResult = \Kimai_Utility_ArrayUtility::arrayDiffAssocRecursive($array1, $array2);
     $this->assertEquals($expectedResult, $actualResult);
 }
Пример #2
0
                 if ($activityID <= 0) {
                     continue;
                 }
                 $data = array();
                 foreach (array('budget', 'effort', 'approved') as $key) {
                     $value = getRequestDecimal($_REQUEST[$key][$index]);
                     if ($value !== null) {
                         $data[$key] = max(0, $value);
                     } else {
                         $data[$key] = "null";
                     }
                 }
                 $database->project_activity_edit($id, $activityID, $data);
             }
             $arrayWithKeysFromValue = Kimai_Utility_ArrayUtility::setKeyFromValue($assignedActivities);
             $itemsToRemove = Kimai_Utility_ArrayUtility::arrayDiffAssocRecursive($projectActivities, $arrayWithKeysFromValue);
             // Remove fixed rate by removed activity assignment
             foreach ($itemsToRemove as $item) {
                 $database->remove_fixed_rate($id, $item);
             }
         } else {
             $database->assignProjectToActivitiesForGroup($id, array(), $kga['user']['groups']);
         }
     }
     header('Content-Type: application/json;charset=utf-8');
     echo json_encode(array('errors' => $errorMessages));
     break;
     /**
      * add or edit a activity
      */
 /**