Write a PHP program to check a specified number is present in a given array of integers.
<?php function test($nums, $n) { if (in_array($n, $nums)) return true; return false; } var_dump(test(array(1,2,9,3), 3)); var_dump(test(array(1,2,2,3), 2)); var_dump(test(array(1,2,2,3), 9));
Sample Output:
bool(true) bool(true) bool(false)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer