Count of array values

Lingam Diaz asked
php arrays
via

Need exact count of values in array.
My result is :

stdClass Object ( [employee] => ["1","2"] )

I want the count value as 2. Is it possible ?

My laravel query :

$work = DB::table('workingdat')
            ->select(DB::raw('employee'))
            ->get();
            $work->toArray($work);
            print_r($work);

I was store JSON data in my table under the column employee.
Example : [“1”,”2”]


Answer
via

If you have this object, as illustrated in your question.

<?php
$object = new StdClass();
$object->employee = array(1, 2);

You can get the count like this:

<?php
$count = count($object->employee); // 2
Share This
Posted in: