Using array values in mysqli_connect

I am reading the database connectivity credentials from a file and storing it in an array .I want to use the values in the array, inside mysql_connect().but i am getting a warning and its not connecting:

Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known. in A:/xamppnew/htdocs/mdb_display.php on line 13
Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No such host is known. in A:/xamppnew/htdocs/mdb_display.php on line 13

Here is my code

    <?php
    $myfile = fopen("db_con.txt", "r") or die("Unable to open file!");
    $db_cred="";
    while(!feof($myfile)) {
        $db_cred[]= fgets($myfile) ;
       }
    fclose($myfile);


    $con = mysqli_connect($db_cred[0],$db_cred[1],$db_cred[2],$db_cred[3]);

 $var="select ulastdatetime from userattedancelog where orgid=1 ";
 $result = $con->query($var);
 $row = $result->fetch_assoc();
 echo $row["ulastdatetime"];
 $dat='#'. $row["ulastdatetime"].'#';

 //closing databse connection
 $con->close();
 ?>

How can i use the values in array in the mysql_connect .

trim your data after gets so that extra new line space can be removed

$myfile = fopen("db_con.txt", "r") or die("Unable to open file!");
    $db_cred=array();
    while(!feof($myfile)) {
        $db_cred[]= trim(fgets($myfile)); //<------------trim data
       }
    fclose($myfile);


    $con = mysqli_connect($db_cred[0],$db_cred[1],$db_cred[2],$db_cred[3]);

 $var="select ulastdatetime from userattedancelog where orgid=1 ";
 $result = $con->query($var);
 $row = $result->fetch_assoc();
 echo $row["ulastdatetime"];
 $dat='#'. $row["ulastdatetime"].'#';

 //closing databse connection
 $con->close();