How do I access a field value for an entity (e.g. node) object?
I guess you do not need to convert $entity into an array,
this would simply work.

$entity-&gt;get('field_name')-&gt;getValue();


FYI : Using kint() from the devel_kint module will let you know all the available methods that could be used to access the object elements, so comparatively var_dump() is less helpful.