object length php code example Example 1: php array length count($myArray); Example 2: how to get length of object in php $total = count((array)$obj);