How to count string frequency in array

I have an array of strings and I want to count how many times one string is found in the array.

For example:

["Harry Potter and the Order of the Phoenix", "Harry Potter and the Order of the Phoenix", "Harry Potter and the Order of the Phoenix", "Harry Potter and the Order of the Phoenix", "Harry Potter and the Order of the Phoenix", "Harry Potter and the Order of the Phoenix", "Harry Potter and the Order of the Phoenix", "Gone with the Wind", "Gone with the Wind", "Gone with the Wind", "Gone with the Wind",""Shopaholic to the Stars (Shopaholic, #7)"", "The Farm", "The Farm", "Men Explain Things to Me", "The Valley of Fear", " The Fellowship of the Ring", " The Fellowship of the Ring", " The Fellowship of the Ring", " The Fellowship of the Ring", " The Fellowship of the Ring", "Mastering the Art of French Cooking", "Play With Me", "Play With Me", "Play With Me", "The Perfect Play", "The Perfect Play", "The Perfect Play", "Dream a Little Dream", "Natural Born Charmer", "Collected Poems", "The Friend Zone"]

I want to return the name of the book and how many times appears in the array.

For example:

  • Harry Potter and the Order of the Phoenix - 5
  • The Fellowship of the Ring - 1

etc...

The two answers you got on the Stack Overflow question should do the trick (I contributed one of those answers as InverseFalcon).

Are there other conditions you need to consider, or ways in which those answers aren't meeting your needs?