getting a target_id value for for users in particular node drupal 8 i want to display a taget_id values for user in node's field but i can't print them , this is what I have done in the hook :

 $node = \Drupal::routeMatch()-&gt;getParameter('node');
  if ($node &amp;&amp; $node-&gt;bundle() == 'MynodeType') {
    $members = $node-&gt;field_members-&gt;getValue();
    $members_ids = [];
    $current_user = \Drupal::currentUser();
    $user_id = \Drupal\user\Entity\User::load($current_user-&gt;id());

    foreach ($members as $member){
      $members_ids[] = $member['target_id'];
      echo $members_ids; // why this is not like (1,8,....)?
    }
Looks like this one has to be solved this way

  $members = $node-&gt;field_members;
  foreach ($members as $member) {
      $members_ids[] = $member-&gt;getValue()['target_id'];
  }