SimplePie_Misc::stripos PHP Method

stripos() public method

Returns the numeric position of the first occurrence of needle in the haystack string.
public stripos ( object $haystack, string $needle, integer $offset ) : boolean
$haystack object
$needle string Note that the needle may be a string of one or more characters. If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.
$offset integer The optional offset parameter allows you to specify which character in haystack to start searching. The position returned is still relative to the beginning of haystack.
return boolean If needle is not found, stripos() will return boolean false.
    function stripos($haystack, $needle, $offset = 0)
    {
        if (function_exists('stripos')) {
            return stripos($haystack, $needle, $offset);
        } else {
            if (is_string($needle)) {
                $needle = strtolower($needle);
            } elseif (is_int($needle) || is_bool($needle) || is_double($needle)) {
                $needle = strtolower(chr($needle));
            } else {
                trigger_error('needle is not a string or an integer', E_USER_WARNING);
                return false;
            }
            return strpos(strtolower($haystack), $needle, $offset);
        }
    }

Usage Example

Example #1
0
 public function __construct($mysql_location, $name, $extension)
 {
     $host = $mysql_location->get_host();
     if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')') {
         $server = ':' . substr($host, 5, -1);
     } else {
         $server = $host;
         if ($mysql_location->get_port() !== null) {
             $server .= ':' . $mysql_location->get_port();
         }
     }
     if (strpos($mysql_location->get_userinfo(), ':') !== false) {
         list($username, $password) = explode(':', $mysql_location->get_userinfo(), 2);
     } else {
         $username = $mysql_location->get_userinfo();
         $password = null;
     }
     if ($this->mysql = mysql_connect($server, $username, $password)) {
         $this->id = $name . $extension;
         $this->options = SimplePie_Misc::parse_str($mysql_location->get_query());
         if (!isset($this->options['prefix'][0])) {
             $this->options['prefix'][0] = '';
         }
         if (mysql_select_db(ltrim($mysql_location->get_path(), '/')) && mysql_query('SET NAMES utf8') && ($query = mysql_unbuffered_query('SHOW TABLES'))) {
             $db = array();
             while ($row = mysql_fetch_row($query)) {
                 $db[] = $row[0];
             }
             if (!in_array($this->options['prefix'][0] . 'cache_data', $db)) {
                 if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))')) {
                     $this->mysql = null;
                 }
             }
             if (!in_array($this->options['prefix'][0] . 'items', $db)) {
                 if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))')) {
                     $this->mysql = null;
                 }
             }
         } else {
             $this->mysql = null;
         }
     }
 }
All Usage Examples Of SimplePie_Misc::stripos