Łączenie tablic

Witam serdecznie,

Mam taki kod:

function stmt_bind_assoc (&$stmt, &$out) {

    $data = mysqli_stmt_result_metadata($stmt);

    $fields = array();

    $out = array();


    $fields[0] = $stmt;

    $count = 1;


    while($field = mysqli_fetch_field($data)) {

        $fields[$count] = &$out[$field->name];

        $count++;

    }    

    call_user_func_array(mysqli_stmt_bind_result, $fields);

}


$cos2 = array();



	$mysqli = new mysqli("localhost", "root", "", "nlove");

	if (mysqli_connect_errno()) {

    printf("Connect failed: %s\n", mysqli_connect_error());

    exit();

}

$cos = array();

if ($stmt = $mysqli->prepare($string)) {

    $stmt->execute(); 

    //$stmt->bind_result($id, $login); 


	 stmt_bind_assoc($stmt, $cos2);


    while ($stmt->fetch()) { 

    array_merge_recursive($cos2, $cos)	; 

	 print_r($cos2);

	 }


	 return $cos2;

    $stmt->close();

}

$mysqli->close()

Gdy próbuję wyświetlić nową, połączoną tablicę :

foreach ($cos2 as $element)

{

	echo $element.', 
';

}

to dostaję tylko ostatni element tej poprzedniej… Co robię nie tak?]

to dostaję tylko ostatni element tej poprzedniej… Co robię nie tak?