How can I efficiently check for both numbers containing the digit three and multiples of three in a PHP loop?

To efficiently check for both numbers containing the digit three and multiples of three in a PHP loop, you can use the modulus operator (%) to check for multiples of three and the strpos function to check for the presence of the digit three in the number. By combining these checks within a loop, you can identify numbers that meet both criteria.

for ($i = 1; $i <= 100; $i++) {
    if ($i % 3 == 0 && strpos($i, '3') !== false) {
        echo $i . " meets both criteria\n";
    }
}