Get array length of a multiple fields of a node content type I'm developing a site with Drupal 8. I made a custom content type, with a lot of fields; in particular I have a field called field_categoria_del_libro_presen that is linked to a taxonomy term. It's possible to specify more than one value. I used kint() to obtain the structure of the node. Here: 

field_categoria_del_libro_presen
→array(2) target_id
  1
    "1"
  2
    "4"


how can I get the length of the array?
Confirmed that as suggested in the comments, the following works quite well:

count($node-&gt;field_categoria_del_libro_presen);


Here the count would be 2 (based on the example in the question).

This works because even though the field_categoria_del_libro_presen property on the node object is a EntityReferenceFieldItemList, it implements (by way of implementing ListInterface) the native PHP \Countable interface.