Order of implode() params insignificant?
| From: | Paul Mullen | Date: | Wed, 29 Nov 2000 23:08:51 +0000 |
| Subject: | Order of implode() params insignificant? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-27907@lists.php.net to get a copy of this message | ||
An quirk in Rasmus Lerdorf's ORA PHP Pocket Reference [1] led me to the
discovery [2] that the order of the parameters used when calling either
implode() or join() seems to be inconsequential. That is, the functions
may be called with the parameters as ($src, $glue) or ($glue, $src), and
work fine in either case. Was this purposeful on the part of the PHP
developers?
Paul
[1] The order of the parameters listed for the implode() function were
the reverse of those specified for the join() function, even though the
online docs claim that, join() an alias of sorts for implode(), they are
identical in their behavior.
[2] I ran the following script as an experiment:
<?PHP
$src = array( "This", "is", "a", "test" );
$glue = '-';
$joined_glue_src = join( $glue, $src );
$joined_src_glue = join( $src, $glue );
$imploded_glue_src = implode( $glue, $src );
$imploded_src_glue = implode( $src, $glue );
echo<<<OUTPUT
join( glue, src ) = $joined_glue_src<br>
join( src, glue ) = $joined_src_glue<br>
<br>
implode( glue, src ) = $imploded_glue_src<br>
implode( src, glue ) = $imploded_src_glue<br>
OUTPUT;
?>