note 87435 added to ref.array

From: Date: Fri, 05 Dec 2008 03:25:38 +0000
Subject: note 87435 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-147657@lists.php.net to get a copy of this message
Hi. I use this function to convert an array into a string, using an optional separator. It can converted back to array (flat array) using the standard PHP split function. <?php /* * Hi! I use this function to convert an array into a string. * Note that to convert back into array (flat array), we can use standard PHP split function. * Here is: */ /*--- Function ARRAY TO STRING --- * * Description: Turns an array into a concatenated string * Arguments: Flat or multidimensional array and optional separator * Example: array(1,2,3,array('x','yz'),4),"-" ---> "1-2-3-x-yz-4" * * Author: Cristiano Galvão * Contact: cristiano@galvao.pro.br * About: http://www.galvao.pro.br * */ function array_to_string( $array, $separator = NULL ) { if( is_array( $array ) ) { foreach( $array as $element ) { $string .= array_to_string( $element, $separator ) . $separator; } $string = substr( $string, 0, strlen( $string ) - strlen( $separator ) ); } else { $string = $array; } return $string; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 201.29.206.121 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/87435 Del: integrated -- https://master.php.net/note/delete/87435/integrated Del: useless -- https://master.php.net/note/delete/87435/useless Del: bad code -- https://master.php.net/note/delete/87435/bad+code Del: spam -- https://master.php.net/note/delete/87435/spam Del: non-english -- https://master.php.net/note/delete/87435/non-english Del: in docs -- https://master.php.net/note/delete/87435/in+docs Del: other reasons-- https://master.php.net/note/delete/87435 Reject -- https://master.php.net/note/reject/87435 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#147657) next »