46 users online (0 members and 46 guests)  

Thread: Array to string


  Results 1 to 4 of 4

Related

  1. Replies: 4
  2. parsing string    Forum: CGI Perl Forum
    Replies: 1
  3. Can I get a variable name as a string?    Forum: PHP Forum
    Replies: 2
  4. array and string manipulation    Forum: CGI Perl Forum
    Replies: 0
  5. unusual string    Forum: Javascript Forum
    Replies: 2
  1. #1
    Zoup's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    8

    Array to string

    I current have an array called $hole[].

    the code is as follows:

    PHP Code:
    $x=1;
    $round_detail_string "";
        foreach (
    $hole as $value){
            
    $round_detail_string += '(null,"'.$x.'","'.$value.'"),';
        } 
    any ideas why this isnt adding the string to the string after it?

    I am trying to create one long insert statement based on the values in the array.

    Any suggestions?

  2. #2
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: Array to string

    += only works for numeric variables.
    Use .=

    Sorry for the terse reply, in a rush

  3. #3
    webchat's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    2

    Re: Array to string

    It's sometime confusing because javascript uses += to concatenate strings - and if you use both languages in a project things like this can slip through...

  4. #4
    c010depunkk's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2007
    Posts
    5

    Re: Array to string

    amen brothers



Tags for this Thread