$con = mysqli_connect("localhost", "username", "password", "dbname"); // perform database operations here mysqli_close($con);
$connections = array(); for ($i = 0; $i < 10; $i++) { $connections[$i] = mysqli_connect("localhost", "username", "password", "dbname"); } // perform database operations here foreach ($connections as $con) { mysqli_close($con); }In this example, an array is created to store 10 MySQLi connection objects. The connections are opened using mysqli_connect() inside a for loop. After performing some database operations, each connection is explicitly closed using a foreach loop and mysqli_close(). Package library: mysqli