the general format of the implode() function are as follows:
i) string implode ( $separator, $array)
ii) string implode ( $array)
iii) string implode ( $array, $separator)
I faced a little problem when “$array” wasn’t just an indexed array
but an associative array (thus array of arrays).
I posted this so I can help someone save 10mins
Solution:
if you have an associative array say $array,
use array_values() as shown in the example below:
implode ( ‘,’, array_values($array))
hope it helps!
S
thx :-)
ReplyDeleteu're welcome Andree
ReplyDeleteThanks, u saved me
ReplyDeleteGlad to have :)
Deleteit is exactly what I am looking for :) Thank you
ReplyDeletegood to know :)
DeleteDanke schon!
ReplyDeletePerfect, thank you!
ReplyDeletewelcome David
ReplyDeleteMight be worth pointing out that according to php.net in php5.4:
ReplyDelete"Converting an array to a string will now generate an E_NOTICE level error, but the result of the cast will still be the string "Array"."
So if you are updating your PHP from 5.3 to 5.4 don't be surprised to see this fix not working. Just getting through debugging around 50 Notices myself now. :)
thnx man ...
ReplyDeleteThanks. Your explanation solved my problem!
ReplyDeletethanks!!
ReplyDeleteThank you, you did help me with this !
ReplyDeleteIt isn't the same thing, but if all you are trying to do is serialize an associative array, consider using json_encode instead.
ReplyDeleteIt still gives me the notice even after using the array_values($array).
ReplyDeleteAny help would be appreciated .
Me, too. I still get the array to string conversion error.
ReplyDeleteyou also get this error when you make a ugly typo.. ;-(
ReplyDeleteimplode ( ‘,’. array_values($array))
when you do a "." instead of a "," ;-)
888sport Review of the online gaming platform in 2021
ReplyDelete888sport, 블랙 잭 만화 an online gaming platform 넷마블바카라 that offers top 브라 벗기기 casino games from bet 분석 around the globe, launched in 2004. The site is powered by 헐리우드 노출 NetEnt's