How to pull and auto display custom fields values to contact form

May be try like this:

foreach( $post_ids->posts as $id):
    // get the post title, and apply any filters which plugins may have added
    // (get_the_title returns unfiltered value)
    $name[] = apply_filters('the_title', get_the_title($id));
    $lname[] = get_post_meta($id, 'last_name', TRUE);
    $address[] = get_post_meta($id, 'address', TRUE);
    $cinfo[] = get_post_meta($id, 'contact_info', TRUE);
endforeach;
$data = ['fname'=>$name, 'lname'=>$lname, 'address'=>$address, 'cinfo'=>$cinfo];
<script>
    $( "#name" ).autocomplete({
      source: <?php echo json_encode($data['fname']]); ?>
    });
    $( "#lname" ).autocomplete({
      source: <?php echo json_encode($data['lname']]); ?>
    });
    $( "#address" ).autocomplete({
      source: <?php echo json_encode($data['address']]); ?>
    });
    $( "#cinfo" ).autocomplete({
      source: <?php echo json_encode($data['cinfo']]); ?>
    });
</script>

error code: 523