Whats the easiest and quickest way to loop through an array of numbers and find out if $val is in there?
Say my array is $numbers(3,5,78,35,78) and my $val=5, it would return true.
Maybe in_array()?
if (in_array($val, $numbers)) {
// Do something
}
No looping required
If you don't care about the position of your number, you could use in_array()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With