Current location: Hot Scripts Forums » Programming Languages » PHP » Find the beginning letter of a word


Find the beginning letter of a word

Reply
  #1 (permalink)  
Old 05-22-05, 06:42 PM
mcrob mcrob is offline
Coding Addict
 
Join Date: Jul 2004
Posts: 266
Thanks: 0
Thanked 0 Times in 0 Posts
Find the beginning letter of a word

Hey there hows everyone doing. Basically Im putting together a CMS for my new website thats coming out soon, where users can upload tutorials, interviews etc.
Im trying too get the first letter of a word so I can insert that into the database for search result purposes

Example. The name of a tutorial is sessions. In that word sessions the beginning word is S. How can I get the first letter of the word and delete the rest of the letters from that word.
__________________
Visit my Online Blog
http://www.robslounge.com
Reply With Quote
  #2 (permalink)  
Old 05-22-05, 06:52 PM
mjac mjac is offline
Newbie Coder
 
Join Date: Dec 2003
Location: England
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
$word = 'sessions';
$letter = $word[0];
The $letter would be s.
__________________
Michael J.A. Clark
My homepage, journal/blog; browser-based development; Solar Empire BBS game
Reply With Quote
  #3 (permalink)  
Old 05-22-05, 09:22 PM
mcrob mcrob is offline
Coding Addict
 
Join Date: Jul 2004
Posts: 266
Thanks: 0
Thanked 0 Times in 0 Posts
mjac your the man

Thank you

I now know how too do is with ease
__________________
Visit my Online Blog
http://www.robslounge.com
Reply With Quote
  #4 (permalink)  
Old 05-23-05, 08:09 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by mjac
Code:
$word = 'sessions';
$letter = $word[0];
The $letter would be s.
weird... how does that work? $word hasnt been set as an array or anything
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
  #5 (permalink)  
Old 05-23-05, 08:56 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Quote:
Originally Posted by FiRe
weird... how does that work? $word hasnt been set as an array or anything
it's called magic

think of strings as an array of chars (like in C)
each char is stored in an element of an array.
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]

Last edited by NeverMind; 05-23-05 at 09:00 AM.
Reply With Quote
  #6 (permalink)  
Old 05-23-05, 09:42 AM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Actuatly
$word{0} not []
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
  #7 (permalink)  
Old 05-23-05, 10:06 AM
hermawan hermawan is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
$word[0] is work also
__________________
Hermawan Haryanto
Senior Programmer - Red Rock Reef LLC
Las Vegas, Nevada 89123 USA
1.800.9.Subnet | Fax: 1.702.920.8277
http://www.redrockreef.com
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the best method to find last word in variable ? GS300 PHP 6 09-15-04 09:13 PM
make money w/ just 6 dollars-legitimate! marilpowe3 General Advertisements 0 02-07-04 02:16 AM


All times are GMT -5. The time now is 06:45 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.