If you know the key for a given array element, whether the key is a string or an integer, finding the matching value is trivial. Doing the opposite is not that difficult, but it does require a bit more effort. In this section, we will show you how to answer questions such as these:
Does an element with a given value exist in an array?
Does an array contain an element with a given key?
At what position can you find an element with a desired value in an array? That is, what key or keys correspond to the value being sought?
How can you find the elements in an array whose values meet a set of criteria or pass a certain test?
What is the best way to find the maximum or minimum value in an array?
How do you apply a function to all the elements in an array?
 Â
You are currently reading a PREVIEW of this book.
                                                                                       Â
Get instant access to over
$1 million worth of books and videos.