Re: Making array to string

From: Date: Wed, 17 Sep 2008 12:58:26 +0000
Subject: Re: Making array to string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-280355@lists.php.net to get a copy of this message
Hunt Jon wrote:
Hi, I'm new to PHP. I have an array that I would like to convert into a string. For example, I have array( 0 => "Good morning", 1 => "Good afternoon", 2 => "Good evening", 3 => "Good night" ); Now I would like to convert the array to something like: "Good morning Good afternoon Good evening Good night". The result has concatanation of each value, but has one space between it. If possible, I would like to insert something like "\n" instead of space. I've been looking into various "array" functions, but I have no clue where to start. Hi,
This one is easy.... It wil 'blow' your mind... $array = array(0 => 'Good morning', 1 => 'Good night'); $str = implode(chr(10), $array); -- Aschwin Wesselius /'What you would like to be done to you, do that to the other....'/

« previous php.general (#280355) next »