Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2004
    Posts
    202
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Regular Coder
    Join Date
    Dec 2004
    Posts
    202
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Regular Coder
    Join Date
    Dec 2004
    Posts
    202
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes sort of is it possible to make it see if it is at begining and not anywhere else in string

  • #6
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •