What is the issue with using in_array() in PHP when checking for a specific string in an array returned from a database query?

The issue with using in_array() in PHP when checking for a specific string in an array returned from a database query is that in_array() performs a loose comparison, which can lead to unexpected results. To solve this issue, you should use strict comparison by checking both the value and the type of the elements in the array.

// Assuming $result is the array returned from the database query
$specificString = 'example';
$found = false;

foreach ($result as $value) {
    if ($value === $specificString) {
        $found = true;
        break;
    }
}

if ($found) {
    echo 'String found in the array.';
} else {
    echo 'String not found in the array.';
}