Actions

API16

JString/strcspn

From Joomla! Documentation

< API16:JString
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

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

[Edit Descripton]

Description:JString/strcspn

Syntax

static 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

public static 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] SeeAlso:JString/strcspn

Examples

<CodeExamplesForm />