/** * @covers Patchwork\Utf8::strpos * @covers Patchwork\Utf8::stripos * @covers Patchwork\Utf8::strrpos * @covers Patchwork\Utf8::strripos */ function testStrpos() { $this->assertSame(false, u::strpos('abc', '')); $this->assertSame(false, u::strpos('abc', 'd')); $this->assertSame(false, u::strpos('abc', 'a', 3)); $this->assertSame(0, u::strpos('abc', 'a', -1)); $this->assertSame(1, u::strpos('한국어', '국')); $this->assertSame(3, u::stripos('DÉJÀ', 'à')); $this->assertSame(1, u::stripos('aςσb', 'ΣΣ')); $this->assertSame(false, u::strrpos('한국어', '')); $this->assertSame(1, u::strrpos('한국어', '국')); $this->assertSame(3, u::strripos('DÉJÀ', 'à')); $this->assertSame(1, u::strripos('aςσb', 'ΣΣ')); $this->assertSame(16, u::stripos('der Straße nach Paris', 'Paris')); }
/** * Find the position of the last occurrence of a string in another string * * @param string $haystack * @param string $needle * * @return mixed * * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0. * Use Patchwork\Utf8::strrpos() instead. */ function utf8_strrpos($haystack, $needle) { @trigger_error('Using utf8_strrpos() has been deprecated and will no longer work in Contao 5.0. Use Patchwork\\Utf8::strrpos() instead.', E_USER_DEPRECATED); return Utf8::strrpos($haystack, $needle); }
/** * Finds the position of last occurrence of a string in a string. * @param string $haystack The string from which to get the position of the last occurrence. * @param string $needle The string to be found. * @param int $offset (optional) $offset may be specified to begin searching an arbitrary position. Negative values will stop searching at an arbitrary point prior to the end of the string. * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default. * @return mixed Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle is not found. * Note: The first character's position is 0, the second character position is 1, and so on. * This function is aimed at replacing the functions strrpos() and mb_strrpos() for human-language strings. * @link http://php.net/manual/en/function.strrpos * @link http://php.net/manual/en/function.mb-strrpos */ function api_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return Utf8::strrpos($haystack, $needle, $offset); }
public function test_linefeed_search() { $str = "Iñtërnâtiônàlizætiø\nn"; $this->assertEquals(19, u::strrpos($str, "\n")); }