Is there a PHP function which will search a string for all forms of the word in regards to casing? (Uppercase, lowercase [it will look for not just Example, but eXaMpLe and eXAMPLE, etc)

if (strip_tags($info['message']) == "menu") {
		$b->sendIm($info['from'], $cMenu);
		sEcho("Received menu command.");
	}

Thanks!

    Your code snippet does not elaborate on what you want to do, but I am guessing that you want either [man]strcasecmp/man or [man]stripos/man.

      Sorry about that snippet -- it doesn't really help and I'm not sure why I put it in.

      if (strip_tags($info['message']) == "menu") { 

      is where I am trying to have it ignore all types of case sensitivity. The user inputs menu, but if they were to input any form of menu it should still accept it. I'm just not sure which function would help with this (if there was any).

        no

        But if you want a find a word, no matter what mix of upper/lower
        you can use strtolower($word) .. or strtoupper($word)
        http://docs.php.net/strtolower

        You can use several Case-Insensitive functions to look for any word in a string.
        stristr() .. is the case-insensitive versin of search function strstr()
        http://docs.php.net/manual/en/function.stristr.php

        http://docs.php.net/manual/en/function.strstr.php

        If you want to find ALL of hits, for a substring
        We have [man]preg_match/man
        http://docs.php.net/manual/en/function.preg-match.php

        This is the most powerful way to search.
        But can be a bit SLOW ( Very advanced PHP functions often are! )
        .. so use a more simple function, if you do no advanced search.

        It is is easy to tell preg_match() / preg_match_all()
        to search for BOTH upper and lower case.

        preg_march_all search for all hits, while preg_match will stop at first found

        http://docs.php.net/manual/en/function.preg-match-all.php

        You also have stripos() .. case-insenstive version of strpos()
        http://docs.php.net/manual/en/function.stripos.php
        http://docs.php.net/manual/en/function.strpos.php

        stristr — Case-insensitive strstr()
        Description
        string stristr ( string $haystack , mixed $needle [, bool $before_needle ] )

        Returns all of haystack from the first occurrence of needle to the end.

        easy example,
        which will search and find a word regardless of any CASE, like in your question

        // $text is where we will search
        // $word can be any string with any CASE mixture
        $search = strtolower( $word );
        $result = stristr( $text, $search);

          is where I am trying to have it ignore all types of case sensitivity. The user inputs menu, but if they were to input any form of menu it should still accept it. I'm just not sure which function would help with this (if there was any).

          Ah, since you want to compare for equality rather than search for existence, strcasecmp() is the function to use.

            Thank you very much -- I understand what I need to do and it now works! 🙂

              You're welcome 🙂
              Remember to mark this thread as resolved using the thread tools.

                Write a Reply...