Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Or even simpler: in_array
If you need to search several times in the same array, then it's better to first make it an array_flip, and then use isset
As an option:
$a = [ 1, 2, 3, 3, 4, 5 ];
$n = array_search(2, array_count_values($a));
echo($n);
If the numbers are in order, then using the sum of an arithmetic progression.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question