eldan88 Posted February 21, 2013 Share Posted February 21, 2013 Hey, I am trying to understand how the stripos() function works, and having a hard time trying to understand it. Can someone please explain me how it works. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/274755-how-does-the-stripos-function-work/ Share on other sites More sharing options...
MySQL_Narb Posted February 21, 2013 Share Posted February 21, 2013 Not too sure if this helps, but there's an entire page on it. http://php.net/manual/en/function.stripos.php Quote Link to comment https://forums.phpfreaks.com/topic/274755-how-does-the-stripos-function-work/#findComment-1413769 Share on other sites More sharing options...
P5system Posted February 21, 2013 Share Posted February 21, 2013 stripos — Find the position of the first occurrence of a case-insensitive substring in a string. For example: stripos(string,find,start); <?php echo stripos("Hello world!","WO"); ?> The output of the code above will be: 6 Quote Link to comment https://forums.phpfreaks.com/topic/274755-how-does-the-stripos-function-work/#findComment-1413788 Share on other sites More sharing options...
Strider64 Posted February 21, 2013 Share Posted February 21, 2013 (edited) I created a simple bad word function using stripos function bad_word_filter($text, $bypass_write=false) { $patterns = array(); //bad words list $patterns[0] = '****'; //Obviously bad words would go here $patterns[1] = '****'; $patterns[2] = '****'; $patterns[3] = '****t'; foreach ($patterns as $check_for_word) { if (stripos($text, $check_for_word) !== false) { $bypass_write = true; // logica value to bypass write to dateabase check. break; } } return $bypass_write; } It's a basic function and simplistic bad words function (though I guess a person could make it more complex if he/she chooses), but it serves it's purpuse for me in my small cms webpage. Pretty neat little function this stripos is. Edited February 21, 2013 by Strider64 Quote Link to comment https://forums.phpfreaks.com/topic/274755-how-does-the-stripos-function-work/#findComment-1413917 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.