ACF – Query relationship without ID

If only 1 value in relation field :

$city_id = $bnb_ville[0]->ID;

if it could be more than 1 value :

$city_id = [];
foreach ($var as $post) {
    $city_id[] = $post->ID;
}

$bnb_ville is the variable for get_field() !