how to identify the POST information?

Hi everyone.!
I’m a beginner in PHP and MySQL , I created a script for a website where people can create groups and can share their ideas direct from dashboard with out going to the Group’s page.
Now the problem is that how I don’t know what to use to identify the First word in POST method , Let me clear myself… For example there’s a field named ‘Share’ on dashboard I Write "CSS hello everyone…!! "
then the PHP should identify the first word in ‘Share’ Field that is ‘CSS’ and then work according to it.This message will be sent Group Named ‘CSS’ as ‘hello everybody…!!’.

Just tell me how to recognize the first word OR the word before first Space.

Waiting for Genius Developer’s Reply…

Hi there,

You could try the following:
[php]$string = ‘CSS hello everybody…!!’;
$words = explode(’ ',$string); //Creates an array -> array(‘CSS’,‘hello’,‘everybody…!!’)
$firstword = $words[0]; //$firstword now equals ‘CSS’
[/php]

:-*
It worked…Thanks a lot bro.

And please tell me how to just echo ‘hello everybody…!!’ eliminating ‘CSS’ ??

Original code (for first word):
[php]$string = ‘CSS hello everybody…!!’;
$words = explode(’ ',$string); //Creates an array -> array(‘CSS’,‘hello’,‘everybody…!!’)
$firstword = $words[0]; //$firstword now equals ‘CSS’[/php]

New code (for everything except first word):
[php]$string = ‘CSS hello everybody…!!’;
$words = explode(’ ‘,$string); //Creates an array -> array(‘CSS’,‘hello’,‘everybody…!!’)
$otherwords = str_replace($words[0].’ ‘,’’,$string); //$otherwords now equals ‘hello everybody…!!’[/php]

If you wanted you could wrap the str_replace() in ucfirst() to give the ‘hello’ a capital H

Thanks a lot for enlightening me bro…
you are the real PHP Hero 8)

I’ll bother you again if I would need more information on PHP.
Thanks again.

My pleasure, glad to have helped.

Sponsor our Newsletter | Privacy Policy | Terms of Service