Problem with array_merge

From: Date: Wed, 22 Mar 2000 23:44:22 +0000
Subject: Problem with array_merge
Groups: php.version4 
Request: Send a blank email to php-version4+get-12507@lists.php.net to get a copy of this message
Hi, I'm trying to put some data into tables using queries built from associative arrays. The only result I get, is an error message from MySQL.... ---snip--- $array1 = array("column1" => $item1, "column2" => $item2); $array2 = array("column3" => $item3); $array3 = array_merge($array1, $array2); $separator = ","; $into_columns = "("; $values = "("; for (reset($values_arr); $name = key($values_arr); next($values_arr)) { $into_columns .= $name; $values .= "'$values_arr[$name]'"; if (next($values_arr)) { $into_columns .= $separator; $values .= $separator; prev($values_arr); } } $into_columns .= ")"; $values .= ")"; ---snip--- Now, $into_columns should look like this (?): (column1,column2,column3), but I always get (column1,column2column3). Same with $values. Before I used array_merge I tried with array_push and array_unshift, but only got empty arrays. Isn't it possible to use those functions with associative arrays or am I doing something wrong? BTW, PHP4.0b4pl1 TIA Martin

« previous php.version4 (#12507) next »