31 $uniqueValues = array_unique($allValues);
32 $valueMultiplicityMap = array();
34 foreach ($uniqueValues as $value) {
36 foreach ($allValues as $candidate) {
37 if ($value == $candidate) {
41 $valueMultiplicityMap[$value] = $count;
44 return $valueMultiplicityMap;
47 public static function callChunked(
Closure $callback, $values, $chunkSize)
49 if ($chunkSize <= 0) {
50 throw new \InvalidArgumentException(
'chunk size should be positive');
53 for ($offset = 0; $offset < count($values); $offset += $chunkSize) {
54 $result = array_merge($result,
55 $callback(array_slice($values, $offset, $chunkSize)));
60 public static function multiSearch($needles,$haystack)
62 foreach ($needles as $needle) {
63 $index = array_search($needle, $haystack);
64 if ($index !==
false) {
static getMultiplicityOfValues($allValues)