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 preparing for archive only
 
(One intermediate revision by the same user not shown)
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}}
 
 


===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>
 
</span>
{{SeeAlso:JString/strpos}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=strpos
  category=strpos
  category=JString
  category=JString
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 02:08, 25 March 2017

Description

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



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);
        }
}



Examples

Code Examples