tags:

views:

50

answers:

2
var_dump(implode(',', array('11','22')));

And

var_dump(implode(array('11','22'), ','));

Which is right?

+5  A: 

According to the documentation on implode():

implode() can, for historical reasons, accept its parameters in either order. For consistency with explode(), however, it may be less confusing to use the documented order of arguments.

The documented description is:

string implode ( string $glue , array $pieces  ) 

implode(',', array('11','22')) (the documented order) is identical to implode(array('11','22'), ',')). Both create the string 11,22.

Peter Ajtai
+1  A: 

Read this:

implode() can, for historical reasons, accept its parameters in either order. For consistency with explode(), however, it may be less confusing to use the documented order of arguments.

Taken from http://php.net/manual/en/function.implode.php

Both are accepted, but as it says above - documented order of arguments should be used.

ShiVik
The above quote should not be taken to mean that both are correct.
thomasrutter
@thomasrutter - I correct myself. `Both are accepted`
ShiVik
cool, downvote removed then I guess :)
thomasrutter