I have a problem. I am trying to count the array keys in my array using an specific element inside my array in the main array
public function index()
{
$user=User::all();
$lead=Lead::all();
$role=Role::all();
$lead=DB::table('lead')
->select(DB::raw('lead.id','users.number','users.username', 'lead.leadid','lead.first_name', 'lead.last_name','lead.email' ,count('lead.email') ))
->where ('lead.email', '>', 1)
->groupBy('lead.email')
->leftJoin('users', 'users.number', '=', 'lead.assign')
->get();
$user=DB::table('users')->select('users.number','users.username')->get();
echo "<pre>";
print_r($lead);
die();
}
Here is the output when I print it out
Array
(
[0] => Array
(
[id] => 63
[number] => 3
[username] => shankar
[leadid] => zcrm_125720000016007771
[first_name] =>
[last_name] => Amoah Owusu Richmond
[email] => ramoahhowusu50@gmail.com
)
[1] => Array
(
[id] => 64
[number] => 3
[username] => shankar
[leadid] => zcrm_125720000016007733
[first_name] => Deus
[last_name] => mathew
[email] => mathewdeus@gmail.com
)
[2] => Array
(
[id] => 65
[number] => 2
[username] => james
[leadid] => zcrm_125720000016007737
[first_name] => bari
[last_name] => safi
[email] => barisafi57@gmail.com
)
[3] => Array
(
[id] => 66
[number] => 11
[username] => nishupandey
[leadid] => zcrm_125720000016007741
[first_name] => Noorahmad
[last_name] => Noor
[email] => noorahmad.noor81@gmail.com
)
[4] => Array
(
[id] => 67
[number] => 12
[username] => ravi123
[leadid] => zcrm_125720000016007747
[first_name] => munsanje
[last_name] => nakeempa
[email] => mnakeempa@yahoo.com
)
[5] => Array
(
[id] => 68
[number] => 8
[username] => veerkishor
[leadid] => zcrm_125720000016007751
[first_name] => Noorahmad
[last_name] => Noor
[email] => noorahmad.noor71@gmail.com
)
[6] => Array
(
[id] => 69
[number] => 13
[username] => rahul
[leadid] => zcrm_125720000016007755
[first_name] => painad
[last_name] => sherzad
[email] => painda12sherzad@gmail.com
)
)
I want to count the elements using the email and check how many times the element is appearing in the array. Am trying to use the array_count_values but am not quite sure how to use it. Thanks in advance