Skip to content

Commit 71166b7

Browse files
authored
substr.xml Remove the redundant mention of the offset (#4759)
The function first determines the starting position of the substring (part of the original string), and then drops abs($length) characters from the tail of this substring if the value of the $length parameter is negative. I don't understand the meaning of the parenthesized notation, and it seems redundant to me; as if the $length parameter behaves differently with a positive offset. My point is that with a negative value of the $offset parameter, the behavior of the $length parameter does not change, so why mention the negative offset separately. Moreover, the end of the original string and the end of the substring that remained after applying the offset are the same ends, no matter how you look at it, and it is from these ends that the function will discard characters.
1 parent bdc3ab3 commit 71166b7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

reference/strings/functions/substr.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ echo substr("abcdef", -3, 1), PHP_EOL; // returns "d"
8080
</para>
8181
<para>
8282
If <parameter>length</parameter> is given and is negative, then that many
83-
characters will be omitted from the end of <parameter>string</parameter>
84-
(after the start position has been calculated when a
85-
<parameter>offset</parameter> is negative). If
86-
<parameter>offset</parameter> denotes the position of this truncation or
83+
characters will be omitted from the end of <parameter>string</parameter>.
84+
If <parameter>offset</parameter> denotes the position of this truncation or
8785
beyond, an empty string will be returned.
8886
</para>
8987
<para>

0 commit comments

Comments
 (0)