SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict brain's Avatar
    Join Date
    Sep 2001
    Location
    Amsterdam
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I know there's a function, but....

    I know there's a function for this, but I can't remember it, can you?

    I have an array, let's say:

    -apple
    -pear
    -grape

    I want to print the array using commas in between:

    apple,pear,grape

    What's the function to achieve this?

  2. #2
    SitePoint Enthusiast jagat_21's Avatar
    Join Date
    Jun 2007
    Location
    Ahmedabad,India
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    u can use implode() function.

    Code PHP:
    <?php
    $newarray = array('apple','pear','grape');
    $str = implode(',',$newarray);
    echo $str;
    ?>

    Check it....

  3. #3
    SitePoint Addict brain's Avatar
    Join Date
    Sep 2001
    Location
    Amsterdam
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's the one !

    Thank you

  4. #4
    SitePoint Addict brain's Avatar
    Join Date
    Sep 2001
    Location
    Amsterdam
    Posts
    249
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    since you're that fast,

    could you give me an regex for

    I want the field of the form to be an digit (year)

    it has to be between 70 years ago and 6 years from now

  5. #5
    SitePoint Enthusiast jagat_21's Avatar
    Join Date
    Jun 2007
    Location
    Ahmedabad,India
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    i dont have much exp. in creating regex. But still i m trying for this 1.

    But this wont be faster

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by brain View Post
    since you're that fast,

    could you give me an regex for

    I want the field of the form to be an digit (year)

    it has to be between 70 years ago and 6 years from now
    You can only use RegEX to check the format.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    And you don't need RegEx for that.
    PHP Code:
    $year intval($_POST['year']);
    $thisyear intval(date('Y'));
    if (
    $year $thisyear 70 || $year $thisyear 6) {
      
    // Display error, etc.
    }
    else {
      
    // Proceed with operation



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
  •