数组值的计数

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"]

Convert your object into an array and then use the count() function of php For example:

$arr = array($your_object);
echo count($arr);

First, you have to typecast your abject into an array.

$array =  (array) $yourObject;

refer this link also : http://www.php.net/manual/en/language.types.array.php

after typecast you can count array value like this.

echo $total = count($array['employee']);

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