Results 1 to 4 of 4

Thread: PHP string function

  1. #1
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP string function

    Hi..guys!What is the string function that cut 01,02,03 to 1,2,3?Thanks...

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    PHP Code:
    str_replace('0'''$string); 
    that would replace all zero's though not just the leading zero's

  3. #3
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Problem resolved,thanks..my string only has a zero in leading position.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    More thorough:
    PHP Code:
    <?php
    $string 
    explode(',',$string);
    foreach (
    $string as $k=>$v) {
    $string[$k] = ($v+1)-1;
    }
    //$string is now fixed
    ?>
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •