Elimina los campos repetidos en un array/objeto de PHP

PHOTO EMBED

Fri Mar 31 2023 17:20:50 GMT+0000 (Coordinated Universal Time)

Saved by @bulmaroarellano #laravel #php

$areasexperiencia = $areasexperiencia;
function unique_key($array,$keyname){
$new_array = array();
foreach($array as $key=>$value){

if(!isset($new_array[$value[$keyname]])){
$new_array[$value[$keyname]] = $value;
}

}
$new_array = array_values($new_array);
return $new_array;
}
$unique_arr = unique_key($areasexperiencia,'nombre');
content_copyCOPY

Funciona con un array asociativo

https://makitweb.com/remove-duplicate-values-from-an-array-in-php/