/    Sign up×
Community /Pin to ProfileBookmark

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’][/CODE]

with this 3-character code so that certain pages permissions will be different based on the type of user.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 19.2011 — [code=php]
$last3chars = substr($string, -3);
[/code]
Copy linkTweet thisAlerts:
@amandaNHTauthorAug 19.2011 — Thanks much! ?
×

Success!

Help @amandaNHT spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...