Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

CHAPTER 4: Working with Arrays > Finding and Working with Array Values

Finding and Working with Array Values

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.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint