string question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cto1mac
Forum Commoner
Posts: 54
Joined: Tue Jan 27, 2004 6:11 am
Location: Virginia Beach, VA

string question

Post by cto1mac »

Ok say I have this:

$var = "A8";

What do I do to get just the "A" from that variable?

Thanks.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

[php_man]substr[/php_man]
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
cto1mac
Forum Commoner
Posts: 54
Joined: Tue Jan 27, 2004 6:11 am
Location: Virginia Beach, VA

Post by cto1mac »

Seriously, you guys on the forums have saved me from ripping my hair out once again.

Thanks
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Alternatively....

$var{0} will return the first character of $var.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

just a question, you can't do $var{0-10}, right?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Right, you can't ;)
Post Reply