function calcetin($tabla) { $res = []; foreach ($tabla as $clave => $valor) { $res[$valor] = $clave; } return $res; } $t = ["a" => 1, "b" => 3, "c" => 1]; muestraTabla($t); $c = calcetin($t); muestraTabla($c); function contar($tabla, $valor) { $cont = 0; foreach ($tabla as $v) { if ($valor == $v) { $cont++; } } return $cont; } echo esUnico1($t); function esUnico1($tabla) { foreach ($tabla as $valor) { if (contar($tabla, $valor) > 1) { return false; } } return true; } function esUnico2($tabla) { $t = array_count_values($tabla); foreach ($t as $valor) { if ($valor > 1) { return false; } } return true; } function esUnico3($tabla){ sort($tabla); for($i=1;$i<count($tabla);$i++){ if ($tabla[$i]==$tabla[$i-1]){ return false; } } return true; } function esUnico4($tabla){ return count($tabla)==count(array_unique($tabla)); }