iconv_substr
Cut out part of a string.
iconv_substr Function synopsis
iconv_substr(
string $string,
int $offset,
?int $length = null,
?string $encoding = null
): string|false
Parameters
$string
Typestring
The original string.
$offset
Typeint
If $offset is non-negative,
iconv_substr cuts the portion out of
$string beginning at $offset'th
character, counting from zero.
$length
OptionalType?intDefault valuenull
If $length is given and is positive, the return
value will contain at most $length characters
of the portion that begins at $offset
(depending on the length of $string).
$encoding
OptionalType?stringDefault valuenull
If $encoding parameter is omitted or null,
$string are assumed to be encoded in
iconv.internal_encoding.
Return value
Typestring|false
Returns the portion of $string specified by the
$offset and $length parameters.
If $string is shorter than $offset
characters long, false will be returned.
If $string is exactly $offset
characters long, an empty string will be returned.
Changes to the iconv_substr Function
PHP 8.0
- Return type added:
string|false - Parameter name of parameter #1 changed:
$strto$string - Parameter type added for parameter #1 (
$string):string - Parameter type added for parameter #2 (
$offset):int - Parameter type added for parameter #3 (
$length):?int - Parameter default value added for position #3 (
$length):null - Parameter name of parameter #4 changed:
$charsetto$encoding - Parameter type added for parameter #4 (
$encoding):?string - Parameter default value added for position #4 (
$encoding):null
iconv_substr(
- $str,
+ string $string,
- $offset,
+ int $offset,
- $length,
+ ?int $length = null,
- $charset
+ ?string $encoding = null
- )
+ ): string|false iconv_substr Function Availability
iconv_substr Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |