note 87405 added to ref.array

From: Date: Thu, 04 Dec 2008 03:21:17 +0000
Subject: note 87405 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-147606@lists.php.net to get a copy of this message
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: <?php /*--- 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: 200.185.109.13 Probable Submitter: 201.29.176.49 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/87405 Del: integrated -- https://master.php.net/note/delete/87405/integrated Del: useless -- https://master.php.net/note/delete/87405/useless Del: bad code -- https://master.php.net/note/delete/87405/bad+code Del: spam -- https://master.php.net/note/delete/87405/spam Del: non-english -- https://master.php.net/note/delete/87405/non-english Del: in docs -- https://master.php.net/note/delete/87405/in+docs Del: other reasons-- https://master.php.net/note/delete/87405 Reject -- https://master.php.net/note/reject/87405 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#147606) next »