Why is the zero-indexed item in my $array not recognised?

<?php
    $array = ["1", "3", "5", "7", "9"];

    $compare = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];

    foreach ($compare as $c) {
        echo '$array ';
        if (array_search($c, $array, true)) {
            echo 'does ';
        } else {
            echo 'does not ';
        }
        echo "contain $c <br>";
    }


results:
$array does not contain 0
$array does not contain 1
$array does not contain 2
$array does contain 3
$array does not contain 4
$array does contain 5
$array does not contain 6
$array does contain 7
$array does not contain 8
$array does contain 9
Was this page helpful?