Skip to content

Instantly share code, notes, and snippets.

@lomotech
Created July 15, 2021 23:47
Show Gist options
  • Save lomotech/7bad60b3315e8c4ff857d13eb5517587 to your computer and use it in GitHub Desktop.
Save lomotech/7bad60b3315e8c4ff857d13eb5517587 to your computer and use it in GitHub Desktop.
array test
// 1. Given an array of [4,1,5,6], write a function that returns to me the lowest number.
// 2. Given an array of strings ['apple', 'banana', 'orange', 'apple'], return an object with the count of each element in the array.
{ 'apple': 2, 'orange': 1, 'banana': 1 }.
$a = [4,1,5,6]
sort($a)
$a[0]
$b = ['apple', 'banana', 'orange', 'apple']
json_encode(array_count_values($b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment