Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2007
    Location
    maine,usa
    Posts
    151
    Thanks
    2
    Thanked 1 Time in 1 Post

    array to string help

    I have a array like so
    PHP Code:
      // results from db
      
    $v[0] = 'blue';
      
    $v[1] = 'red';
      
    $v[2] = 'green';
     
    // the size of the array can change based on the number of the colors for each product

    // I need to output it in a input text box like the following
     
    $value 'blue,red,green';

    // I figure some type of loop but I' don't know which one 
    Just a simple Developer and IT student
    My Blog
    My Portfolio
    My Playground of Technology

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Code:
    $value = implode(',', $v);
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    Regular Coder
    Join Date
    Aug 2007
    Location
    maine,usa
    Posts
    151
    Thanks
    2
    Thanked 1 Time in 1 Post
    thanks I didn't realize the implode made it s string.
    Just a simple Developer and IT student
    My Blog
    My Portfolio
    My Playground of Technology

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    What else would it have been turned into?


  •  

    Posting Permissions

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