Function Reference: geodir_utf8_substr

Summary

Get the part of string.

Package

Geodirectory

Parameters

$str
(string) (required) The string to extract the substring from.

Default: None
$start
(int) (required) If start is non-negative, the returned string will start at the entered position in string, counting from zero. If start is negative, the returned string will start at the entered position from the end of string.

Default: None
$length
(int|null) (required) Maximum number of characters to use from string.

Default: None
$encoding
(string) (required) The encoding parameter is the character encoding.

Default: “UTF-8”

Return Values

(string)

    Change Log

    Since: 1.6.18

    Source File

    geodir_utf8_substr() is located in geodirectory-functions/helper_functions.php [Line: 1175]

    Source Code

    function geodir_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
        if ( function_exists( 'mb_substr' ) ) {
            if ( $length === null ) {
                return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding );
            } else {
                return mb_substr( $str, $start, $length, $encoding );
            }
        }
            
        return substr( $str, $start, $length );
    }