php oop foreach code example Example: php loop through objects foreach ($obj as $key => $value) { echo "$key => $value\n"; }