faqts : Computers : Programming : Languages : PHP : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 11 people (91%) answered Yes
Recently 1 of 2 people (50%) answered Yes

Entry

Problem with implode() $a[0]="A"; $a[1]="B"; implode( $a, ";" ) results "A;A;B;B" - what's wrong?

Apr 18th, 2000 22:53
Cameron Hayne, Onno Benschop, Juergen Eder, unknown unknown,


I'm guessing that you're re-using an array that has the following items:

$a[0]=A
$a[A]=A
$a[1]=B
$a[B]=B

This generally happens when you get the array from a database like 
MySQL using mysql_fetch_array() instead of mysql_fetch_row().

FYI, php manual: http://www.phpbuilder.com/manual/function.implode.php3

----
Umm, that phpbuilder page would seem to be in error since the php.net 
manual page at http://www.php.net/manual/function.implode.php3 says that 
the order of the arguments is: 1) glue string 2) array
and hence the call to the function should be implode(";" $a) instead of 
the above.
... Cameron Ha