www.webdeveloper.com
Results 1 to 3 of 3

Thread: get the last 3 characters in a string

  1. #1
    Join Date
    Apr 2011
    Location
    Seattle, WA
    Posts
    265

    Question get the last 3 characters in a string

    How do you get the last 3 characters of a string?

    I have usernames set up with a 3-character "code" at the end for the type of user... for example, agents are "agt" so their usernames all end in agt

    How do I use PHP to catch these letters so that the type can be set while they're logged in?

    I need to set
    Code:
    $_SESSION['type']
    with this 3-character code so that certain pages permissions will be different based on the type of user.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,246
    PHP Code:
    $last3chars substr($string, -3); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Apr 2011
    Location
    Seattle, WA
    Posts
    265
    Thanks much!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles