...

View Full Version : Php help searching string



Kura_kai
06-17-2005, 08:20 PM
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.

raf
06-17-2005, 08:54 PM
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...

Kura_kai
06-17-2005, 09:09 PM
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.

raf
06-17-2005, 09:26 PM
not completely sure i get it, so here's my first idea:


if (strpos($userinput, '/nickchange')!==False){
$nickname = str_replace('/nickchange ', '', $userinput)
}

is it something like this you wanna do?

Kura_kai
06-17-2005, 09:31 PM
yes sort of is it possible to make it see if it is at begining and not anywhere else in string

raf
06-17-2005, 10:17 PM
sure:


if (strpos($userinput, '/nickchange')===0){
$nickname = str_replace('/nickchange ', '', $userinput);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum