mardi 7 janvier 2020

How to count multidimensional object? (php)

I have a Laravel Collection value returned below:

image

My question is how to count the total no. of data contained each. Like the example above I must have a result value of 9 with that example.

I tried the below code:

array_count_values($jobs)

But as expected it returns an error:

array_count_values() expects parameter 1 to be array, object given


Someone knows how to achieve this either in native php way or laravel collection methods?

via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire