[ create a new paste ] login | about

Link: http://codepad.org/GHB17CQb    [ raw code | output | fork ]

PHP, pasted on Jan 14:
<?

$needles = array(
   "orange",
   "maroon",
   "red",
   "violet",
   "pink",
   "gray",
   "navy"
);
$haystack = array(
   "blue",
   "green",
   "red",
   "black"
);

$needlesCount = count($needles);
for ($i = 0; $i < $needlesCount; $i++) {

    $PoS = array_search($needles[$i], $haystack, true);
    if ($PoS !== false) {
    echo ("found");
    }
    else { echo ("not found"); }
echo "\n";
}


Output:
1
2
3
4
5
6
7
not found
not found
found
not found
not found
not found
not found


Create a new paste based on this one


Comments: