Results 1 to 3 of 3

Thread: [RESOLVED] Left & Right

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Location
    United States
    Posts
    157

    Resolved [RESOLVED] Left & Right

    Hello
    I set a string "abcdefg".
    How can I return a string containing a specified number of characters from the left or right side of the string I set?

    Example:
    If I want to return 3 characters from the left of the string above, it'll print "abc".

    In VB6, I can do that by "Left$(str,Length)" or "Right$(str,Length)".

    Thanks

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Left & Right

    Use the SubStr function.

    Check out the exmples below.

    PHP Code:
    echo substr('abcdef'1);    // bcdef
    echo substr('abcdef'13);  // bcd
    echo substr('abcdef'04);  // abcd
    echo substr('abcdef'08);  // abcdef
    echo substr('abcdef', -11); // f 

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Location
    United States
    Posts
    157

    Re: [RESOLVED] Left & Right

    Thank you very much for helping.

Posting Permissions

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



Click Here to Expand Forum to Full Width