Re: [PHP4BETA] Problem with array_merge

From: Date: Thu, 23 Mar 2000 13:57:31 +0000
Subject: Re: [PHP4BETA] Problem with array_merge
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-12529@lists.php.net to get a copy of this message
On Thu, 23 Mar 2000, Martin Samesch wrote: > ---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? I'm not aware of any problems with array_merge(). Put var_dump($array3) after the array_merge() and you'll see that it functions properly. Also, in your example I'm not sure where $values_arr is coming from. -Andrei * Anything will fit if you push hard enough *

« previous php.version4 (#12529) next »