$value) { if (is_array($value) || $value instanceof Illuminate\Support\Collection) { if (! isset($arrayTwo[$key])) { $difference[$key] = $value; } elseif (! (is_array($arrayTwo[$key]) || $arrayTwo[$key] instanceof Illuminate\Support\Collection)) { $difference[$key] = $value; } else { $new_diff = array_diff_assoc_recursive($value, $arrayTwo[$key]); if ($new_diff != false) { $difference[$key] = $new_diff; } } } elseif (! isset($arrayTwo[$key])) { $difference[$key] = $value; } } return $difference; } } if (! function_exists('str_before')) { /** * Get the portion of a string before a given value. * * @param string $subject * @param string $search * @return string */ function str_before($subject, $search) { return $search === '' ? $subject : explode($search, $subject)[0]; } } // Array undot if (! function_exists('array_undot')) { /** * Expands a single level array with dot notation into a multi-dimensional array. * * @param array $dotNotationArray * @return array */ function array_undot(array $dotNotationArray) { $array = []; foreach ($dotNotationArray as $key => $value) { // if there is a space after the dot, this could legitimately be // a single key and not nested. if (count(explode('. ', $key)) > 1) { $array[$key] = $value; } else { Arr::set($array, $key, $value); } } return $array; } }