[ PHP ] How do I select a word from a string?

Hello. I have sentence "Lunoxx sold a car.".
I just select "Lunoxx" and "car", how can I do this?

Thanks ! Sorry for my bad english

I am not sure what you exactly want, do you want a function get fetch a specific word of the sentence ?

Either way you could use sscanf like that
pawn Код:
new word1[32], word2[32];
sscanf("Lunoxx sold a car", "s{ss}s", word1, word2);

Yes, but I want it in PHP.

You can use split.
PHP код:
$testString "Lunoxx sold a car."//Set the string to a test.
$splitText explode(' '$testString); //Now the actual code to split it from spaces.

//Now use it.
echo $splitText[0]; //Will print "Lunoxx" 

Forum Jump:

Users browsing this thread: