SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Array ?

  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Denmark
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Array ?

    How do i reverse a array of strings to only one string so that i can insert it to a mysql database or sent the data by mail.

    PHP Code:

    foreach($elements as $key => $word) {

    echo 
    "$word<br>";



  2. #2
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That works(I assume you meant)
    PHP Code:
    foreach ($elements as $key => $value) {
      echo 
    "$value<br/>";

    as does
    PHP Code:
    echo implode('<br/>'$elements); 
    TuitionFree — a free library for the self-taught
    Anode Says...Blogging For Your Pleasure

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Denmark
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have solved the mysteria myself :-)
    I used the implode function

    PHP Code:

    $elements
    implode(", ",$elements);

    $sql "INSERT INTO form SET
                data='
    $elements'";

    if (@
    mysql_query($sql)) {
        echo(
    'New joke added');
      } else {
        die(
    '<p>Error adding new joke: ' .
            
    mysql_error() . '</p>');
      }


    print 
    $elements

  4. #4
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    Denmark
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank for your quick answer anode. It´s funny just as i hat solved the problem myself i resieved your reply :-)


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
  •