strpos...

git-svn-id: file:///svn/phpbb/trunk@6457 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2006-10-07 16:49:44 +00:00
parent eac1b02843
commit c40783e6a2
3 changed files with 8 additions and 13 deletions

View file

@ -2064,7 +2064,7 @@ function get_context($text, $words, $length = 400)
{
if (preg_match('#(?:[^\w]|^)(' . str_replace('\*', '\w*?', preg_quote($word, '#')) . ')(?:[^\w]|$)#i', $text, $match))
{
$pos = strpos($text, $match[1]);
$pos = utf8_strpos($text, $match[1]);
if ($pos !== false)
{
$word_indizes[] = $pos;

View file

@ -445,7 +445,7 @@ class bbcode_firstpass extends bbcode
$code = preg_replace('#(?:[\n\r\s\t]|&nbsp;)*</span>$#', '</span>', $code);
// remove newline at the end
if (!empty($code) && $code{utf8_strlen($code)-1} == "\n")
if (!empty($code) && $code{strlen($code)-1} == "\n")
{
$code = substr($code, 0, -1);
}
@ -499,14 +499,15 @@ class bbcode_firstpass extends bbcode
$tok = ']';
$out = '[';
// First character is [
$in = substr($in, 1);
$list_end_tags = array();
do
{
$pos = strlen($in);
$tok_len = strlen($tok);
for ($i = 0; $i < $tok_len; ++$i)
for ($i = 0, $tok_len = strlen($tok); $i < $tok_len; ++$i)
{
$tmp_pos = strpos($in, $tok{$i});

View file

@ -7,9 +7,9 @@
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @todo make sure the replacements are called correctly
* already done: strtolower, strtoupper, ucfirst, str_split, strrpos, strlen (hopefully!)
* already done: strtolower, strtoupper, ucfirst, str_split, strrpos, strlen (hopefully!), strpos
* remaining: clean_username, htmlentities (no longer needed for internal data?), htmlspecialchars (using charset), html_entity_decode (own function to reverse htmlspecialchars and not htmlentities)
* substr, strpos, strspn, chr, ord
* substr, strspn, chr, ord
*/
/**
@ -192,13 +192,7 @@ if (extension_loaded('mbstring'))
/**
* UTF-8 aware alternative to strpos
* Find position of first occurrence of a string
*
* @author Harry Fuecks
* @param string haystack
* @param string needle
* @param integer offset in characters (from left)
* @return mixed integer position or FALSE on failure
* @ignore
*/
function utf8_strpos($str, $needle, $offset = null)
{