API15

API15:JString/strcspn

From Joomla! Documentation

Revision as of 22:25, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== UTF-8 aware alternative to strcspn Find length of initial segment not matching mask <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

UTF-8 aware alternative to strcspn Find length of initial segment not matching mask

[Edit Descripton]

Template:Description:JString/strcspn

Syntax

strcspn($str, $mask, $start=NULL, $length=NULL)
Parameter Name Default Value Description
$str
$mask the mask
$start NULL Optional starting character position (in characters)
$length NULL Optional length

Returns

int the length of the initial segment of str1 which does not contain any of the characters in str2

Defined in

libraries/joomla/utilities/string.php

Importing

jimport( 'joomla.utilities.string' );

Source Body

function strcspn($str, $mask, $start = NULL, $length = NULL)
{
        jimport('phputf8.strcspn');
        if ( $start === FALSE && $length === FALSE ) {
                return utf8_strcspn($str, $mask);
        } else if ( $length === FALSE ) {
                return utf8_strcspn($str, $mask, $start);
        } else {
                return utf8_strcspn($str, $mask, $start, $length);
        }
}

[Edit See Also] Template:SeeAlso:JString/strcspn

Examples

<CodeExamplesForm />