Home > Blockchain >  Laravel Livewire: How to check if all values in an array is False or True?
Laravel Livewire: How to check if all values in an array is False or True?

Time:11-30

How to check if all values in an array is all false or true? So I have created a checkbox for selecting students(wire:model="selectedStudents.{{ $stud->id }}").

The resulting array is like this [4 => true 5 => true 6 => false] somehow i need to disable a function in my controller if all values is true or false. Please help me.

CodePudding user response:

in_array php function should work.

in_array(true, $this->selectedStudents) {
    // all values are true
} else {
   // 1   N are false
}

of course, always the array have items

  • Related