note 87386 added to ref.array
| From: | cristiano at galvao dot pro dot br | Date: | Tue, 02 Dec 2008 23:40:49 +0000 |
| Subject: | note 87386 added to ref.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-147572@lists.php.net to get a copy of this message | ||
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
----
Server IP: 69.147.83.197
Probable Submitter: 201.8.45.97
----
Manual Page -- http://www.php.net/manual/en/ref.array.php
Edit -- https://master.php.net/note/edit/87386
Del: integrated -- https://master.php.net/note/delete/87386/integrated
Del: useless -- https://master.php.net/note/delete/87386/useless
Del: bad code -- https://master.php.net/note/delete/87386/bad+code
Del: spam -- https://master.php.net/note/delete/87386/spam
Del: non-english -- https://master.php.net/note/delete/87386/non-english
Del: in docs -- https://master.php.net/note/delete/87386/in+docs
Del: other reasons-- https://master.php.net/note/delete/87386
Reject -- https://master.php.net/note/reject/87386
Search -- https://master.php.net/manage/user-notes.php