note 87386 deleted from ref.array by danbrown
| From: | danbrown@php.net | Date: | Tue, 02 Dec 2008 23:43:57 +0000 |
| Subject: | note 87386 deleted from ref.array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147575@lists.php.net to get a copy of this message | ||
Note Submitter: cristiano at galvao dot pro dot br
----
I use this function to convert an array into a string:
//<--- ARRAY TO STRING:
function array_to_string( $array, $separator = NULL ) {
if( is_array( $array ) ) {
foreach( $array as $element ) {
$string .= $element . $separator;
}
$string = substr( $string, 0, strlen( $string ) - strlen( $separator ) );
}
return $string;
}
The separator is optional. Note that if we want to convert back into an array, we just need to use
the standard PHP split function.
Cristiano Galvão
http://www.galvao.pro.br