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! 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 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 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 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. 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
Archived
This topic is now archived and is closed to further replies.