I am using laravel, I am getting this error when trying to count the valuse of this array.
Error:array_count_values(): Can only count STRING and INTEGER values!
the function:
public function test()
{
$test = \DB::table('surveys')->where('company_id', '=', 1)->select('rd1')->get()->toArray();;
$c = array_count_values($test);
$val = array_search(max($c), $c);
return view ('companies.test', compact('val'));
}
here is a var_dump of $test:
array:4 [▼
0 => {#204 ▼
+"rd1": "option1"
}
1 => {#206 ▼
+"rd1": "option1"
}
2 => {#207 ▼
+"rd1": "option1"
}
3 => {#208 ▼
+"rd1": "option1"
}
]