API16

JString/strpos: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== UTF-8 aware alternative to strpos Find position of first occurrence of a string <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JSt...
 
m clean up
Line 2: Line 2:
UTF-8 aware alternative to strpos Find position of first occurrence of a string
UTF-8 aware alternative to strpos Find position of first occurrence of a string


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JString/strpos|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JString/strpos}}
 
{{subst:Description:JString/strpos}}


===Syntax===
===Syntax===
Line 50: Line 48:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JString/strpos|Edit See Also]]<nowiki>]</nowiki>
{{subst:SeeAlso:JString/strpos}}
</span>
{{SeeAlso:JString/strpos}}


===Examples===
===Examples===

Revision as of 14:28, 24 March 2017

Description

UTF-8 aware alternative to strpos Find position of first occurrence of a string


{{subst:Description:JString/strpos}}

Syntax

static strpos($str, $search, $offset=FALSE)
Parameter Name Default Value Description
$str - string String being examined
$search - string String being searced for
$offset FALSE - int Optional, specifies the position from which the search should be performed

Returns

mixed Number of characters before the first match or FALSE on failure

Defined in

libraries/joomla/utilities/string.php

Importing

jimport( 'joomla.utilities.string' );

Source Body

public static function strpos($str, $search, $offset = FALSE)
{
        if ( $offset === FALSE ) {
                return utf8_strpos($str, $search);
        } else {
                return utf8_strpos($str, $search, $offset);
        }
}


{{subst:SeeAlso:JString/strpos}}

Examples

<CodeExamplesForm />