What would be the best approach to create the function getMostFrequentlyOccurringItem()
below?
//should return "paragraph"
echo getMostFrequentlyOccurringItem(array('line', 'paragraph', 'paragraph'));
//should return "line"
echo getMostFrequentlyOccurringItem(array('wholeNumber', 'line', 'line', 'line'));
//should return null
echo getMostFrequentlyOccurringItem(array('wholeNumber', 'wholeNumber', 'paragraph', 'paragraph'));
//should return "wholeNumber"
echo getMostFrequentlyOccurringItem(array('wholeNumber', '', '', ''));
function getMostFrequentlyOccurringItem($items) {
//...
}
Answer:
Thanks Adam, here's my finished solution: http://tanguay.info/web/index.php?pg=codeExamples&id=396