In PHP, how do I search arrays with strong typing?

Keywords: PHP, Strong Typing, Array Search, Type Safety, PHP 7+
Description: This example demonstrates how to search arrays in PHP with strong typing. Strong typing improves code reliability and prevents type errors.
<?php declare(strict_types=1); // Enable strong typing function searchArray(array $arr, int $target): bool { foreach ($arr as $value) { if ($value === $target) { return true; // Found the target } } return false; // Target not found } $numbers = [1, 2, 3, 4, 5]; $found = searchArray($numbers, 3); if ($found) { echo "Number found!"; } else { echo "Number not found."; } ?>

Keywords: PHP Strong Typing Array Search Type Safety PHP 7+