Welcome Guest, Not a member yet? Register   Sign In
Validation for duplicated on form
#6

(This post was last modified: 06-19-2023, 11:24 AM by JustJohnQ.)

array_unique is a php function. A custom rule like this will probably work:
See: https://codeigniter4.github.io/userguide...stom-rules
PHP Code:
<?php

class MyRules
{
    public function duplicates($serialarray): bool
    
{
$originalLength count($serialArray);
$duplicateArray array_unique($serialArray);
$duplicateLength count($duplicateArray); 
if (
$originalLength <> $duplicateLength){
return 
0;
}else{
return 
1;
    }

Reply


Messages In This Thread
RE: Validation for duplicated on form - by JustJohnQ - 06-19-2023, 04:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB