SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast digitalbart's Avatar
    Join Date
    Apr 2002
    Location
    chicago
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    convert array to string

    how can turn an array into a string. i want to echo a string in a word document and if i use an array all i get is the last value of the array.

  2. #2
    SitePoint Addict Quaint's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't echo an array, you need to loop through it and echo the values one by one:

    PHP Code:
    $array = array ("value""another""value);

    foreach ( 
    $array as $string )
    {
      echo 
    $string . "<BR>\n";
    }

    // Or:

    foreach ( 
    $array as $string )
    {
      
    $newString .= $string . " ";
    }
    echo 
    $newString
    Or whatever you want to do with it!

    Quaint Tech
    - Blog on web development and web technology.

  3. #3
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can convert an array back to a string using implode.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  4. #4
    SitePoint Addict Quaint's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vinyl-junkie
    You can convert an array back to a string using implode.
    Oh yeah, that's right :P haha, implode is easier indeed!

    Quaint Tech
    - Blog on web development and web technology.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •