$data] ; } public function display_duplicated_emails ($emails) { $duplicates = array_diff_key($emails, array_unique($emails)); if(!empty($duplicates)){ $error = []; foreach ($duplicates as $key => $duplicate) { $error[] = $duplicate ." has already duplicate in json"; } return response()->json(compact('error'),400); } } } //class