Get values from unlimted field programmatically in node_presave hook I have created class content type and set Allowed number of values to unlimited" to "Division" field
Now I want to get "Division" field values programmatically in node presave hook I'm using below code.

function example_node_presave(Drupal\Core\Entity\EntityInterface $node){
  if($node-&gt;bundle() == "class") {
     $getDivison = $node-&gt;get('field_class_division')-&gt;target_id;
   }
}


If i print $getDivison then I get 739 only.
You can loop over a field object and access each item separately, that's often more convenient than going through getValue():

function example_node_presave(Drupal\Core\Entity\EntityInterface $node){

  if($node-&gt;bundle() == "class") {
     foreach ($node-&gt;get('field_class_division') as $item) {
       echo $item-&gt;target_id;
     }
   }
}


And to access a specific delta (that's what the index in a multi-value field is called in the Field API), you can access it like an array as well, but you need to make sure that the deltas exist:

echo $node-&gt;get('field_class_division')[1]-&gt;target_id


See https://wizzlern.nl/drupal/drupal-8-entity-cheat-sheet for a very useful cheat sheet on how to work with the Entity Field API.