...

View Full Version : Retrieving From Database the first word of a sentence



jeffry
02-01-2007, 10:43 AM
I have a column named 'name' in my table 'TEAM'(Using Mysql).I have entered values such as

Martin Davis
Kiran Rathore
Naveen krishnan
Prajith V M

I want these values to be retrieved in a PHP form as

Martin
Kiran
Naveen
prajith

How to do this?Please help.

koyama
02-01-2007, 01:34 PM
There are probably many ways. In your case this would suffice:


$name = 'Martin Davis';
$words = explode(' ', $name);
echo $words[0]; // outputs 'Martin'



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum