faqts : Computers : Programming : Languages : PHP : Common Problems : Strings

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

how can i turn values stored in a array into one string

Apr 11th, 2002 05:10
Mike Ford, Espen Roland,


Use the implode() function.

For example:
 
    $a = array('one', 'two', 'three');
    $all = implode('', $a);

will set $all to 'onetwothree'.

The first parameter of implode, given as the empty string above, is 
text to insert between the original elements -- so, for example:
 
    $a = array('one', 'two', 'three');
    $all = implode(', ', $a);

would set $all to 'one, two, three'.