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