Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-17-2005, 07:20 PM   PM User | #1
Kura_kai
Regular Coder

 
Join Date: Dec 2004
Posts: 202
Thanks: 0
Thanked 0 Times in 0 Posts
Kura_kai is an unknown quantity at this point
Php help searching string

i need help in creating to function that search a string for different things. what i need is that each one searches for a specific string at the begining and than takes the rest into a string and takes away the space infront of it. Any help will be apreciated.
Kura_kai is offline   Reply With Quote
Old 06-17-2005, 07:54 PM   PM User | #2
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
best post some examples of the values you wanna search in + the desired output for these searches.
that way we can write out the code you need. Now it's a bit to vague...
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 06-17-2005, 08:09 PM   PM User | #3
Kura_kai
Regular Coder

 
Join Date: Dec 2004
Posts: 202
Thanks: 0
Thanked 0 Times in 0 Posts
Kura_kai is an unknown quantity at this point
ok sorry this is for a chat room i am making what i want this to work if they type in "/nickchange" or "/me" at the begining.
For example if they type in
/nickchange Bob
the first function looks for "/nickchange" so it would take that message than it goes and takes out the "Bob" and just stores it in a variable
The other function works if they type in "/me" at the begining like this
/me Test
it searches for the "/me" and takes out "Test" and stores it.
and if you see the quotes they are just there so you know what i what it to search for and output without spaces. And the functions should only work if "/me" and "/nickchange" or at the begining.
Kura_kai is offline   Reply With Quote
Old 06-17-2005, 08:26 PM   PM User | #4
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
not completely sure i get it, so here's my first idea:
PHP Code:
if (strpos($userinput'/nickchange')!==False){
    
$nickname str_replace('/nickchange '''$userinput)     

is it something like this you wanna do?
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 06-17-2005, 08:31 PM   PM User | #5
Kura_kai
Regular Coder

 
Join Date: Dec 2004
Posts: 202
Thanks: 0
Thanked 0 Times in 0 Posts
Kura_kai is an unknown quantity at this point
yes sort of is it possible to make it see if it is at begining and not anywhere else in string
Kura_kai is offline   Reply With Quote
Old 06-17-2005, 09:17 PM   PM User | #6
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
sure:
PHP Code:
if (strpos($userinput'/nickchange')===0){
  
$nickname str_replace('/nickchange '''$userinput);     

__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:05 AM.


Advertisement
Log in to turn off these ads.