[PHP] Use strict comparison with in_array()

Created on November 30, 2026

You can pass true as the third argument to in_array() to compare both the value and its type. In this example, the integer 123 does not match the string '123' in the array.

<?php

$haystack = [
    '123',
    '456',
    '789',
];

var_dump(in_array(123, $haystack, true));
bool(false)
PHP