JBZoo\Utils\Str::ipos PHP Method

ipos() public static method

Finds position of first occurrence of a string within another, case insensitive
public static ipos ( string $haystack, string $needle, integer $offset ) : integer
$haystack string
$needle string
$offset integer
return integer
    public static function ipos($haystack, $needle, $offset = 0)
    {
        if (self::isMBString()) {
            return mb_stripos($haystack, $needle, $offset, self::$encoding);
        } else {
            // @codeCoverageIgnoreStart
            return stripos($haystack, $needle, $offset);
            // @codeCoverageIgnoreEnd
        }
    }

Usage Example

Example #1
0
 public function testMBString()
 {
     isSame(Str::isMBString(), function_exists('mb_strtoupper'));
     isSame(Str::isOverload(), (int) ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING);
     is(5, Str::len('Денис'));
     isSame(1, Str::pos('Денис', 'е'));
     isSame(false, Str::pos('Денис', 'Е'));
     isSame(3, Str::rpos('Денис', 'и'));
     isSame(1, Str::ipos('Денис', 'Е'));
     isSame(1, Str::ipos('Денис', 'Е'));
     isSame('енис', Str::strstr('Денис', 'е'));
     isSame('енис', Str::istr('Денис', 'Е'));
     isSame('ис', Str::rchr('Денис', 'и'));
     isSame('нис', Str::sub('Денис', 2));
     isSame('ени', Str::sub('Денис', 1, 3));
     isSame('денис', Str::low('ДЕНИС'));
     isSame('ДЕНИС', Str::up('денис'));
     isSame(2, Str::subCount('денис ДеНИС', 'е'));
     isSame(1, Str::subCount('денис ДеНИС', 'И'));
     isTrue(Str::isStart('денис', 'ден', true));
     isTrue(Str::isStart('денис', 'ДЕН', false));
     isFalse(Str::isStart('денис', 'ДЕН', true));
     isTrue(Str::isEnd('денис', 'нис', true));
     isTrue(Str::isEnd('денис', 'НИС', false));
     isFalse(Str::isEnd('денис', 'ДЕНИС', true));
 }