Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

karimali1337's avatar

in_array(): Argument #2 ($haystack) must be of type array, null given

there's 3 checkboxs when i create the record i may select or not, if i did't select it gives me this error also i'm doing if condition to be if not null so it shouldn't work but idk it gives this error

in_array(): Argument #2 ($haystack) must be of type array, null given
 @if ($permit->job_type != null)
<div class="col-md-5">
 <label for="job_type_1">السقالات</label>
<input type="checkbox"
@if (in_array(1, json_decode($permit->job_type))) disabled checked @else disabled @endif>
<label for="job_type_2">الكهرباء</label>
 <input type="checkbox"
 @if (in_array(2, json_decode($permit->job_type))) disabled checked @else disabled @endif>
 <label for="job_type_3">الونش \الرافعة</label>
<input type="checkbox"
 @if (in_array(3, json_decode($permit->job_type))) disabled checked @else disabled @endif>
 </div>
  @endif
0 likes
4 replies
karimali1337's avatar

@MichalOravec i gotta an idea its working but idk if its the best approach, making this column in the db default [0] so its always not null also its not one of the checkboxs value

Please or to participate in this conversation.