[doc-en] master: substr.xml Remove the redundant mention of the offset (#4759)

From: Date: Wed, 15 Oct 2025 14:39:20 +0000
Subject: [doc-en] master: substr.xml Remove the redundant mention of the offset (#4759)
Groups: php.doc.cvs 
Request: Send a blank email to [email protected] to get a copy of this message
Author: Mikhail Alferov (mmalferov)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2025-10-15T15:39:18+01:00

Commit: https://github.com/php/doc-en/commit/71166b721ba6bb7dd3110da86efa3b723e1f7651
Raw diff: https://github.com/php/doc-en/commit/71166b721ba6bb7dd3110da86efa3b723e1f7651.diff

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.

Changed paths:
  M  reference/strings/functions/substr.xml


Diff:

diff --git a/reference/strings/functions/substr.xml b/reference/strings/functions/substr.xml
index 2f72222d9a1a..321b546b133a 100644
--- a/reference/strings/functions/substr.xml
+++ b/reference/strings/functions/substr.xml
@@ -80,10 +80,8 @@ echo substr("abcdef", -3, 1), PHP_EOL; // returns "d"
       </para>
       <para>
        If <parameter>length</parameter> is given and is negative, then that many
-       characters will be omitted from the end of <parameter>string</parameter>
-       (after the start position has been calculated when a
-       <parameter>offset</parameter> is negative).  If
-       <parameter>offset</parameter> denotes the position of this truncation or
+       characters will be omitted from the end of <parameter>string</parameter>.
+       If <parameter>offset</parameter> denotes the position of this truncation or
        beyond, an empty string will be returned.
       </para>
       <para>


Thread (1 message)

  • Mikhail Alferov via GitHub
« previous php.doc.cvs (#22810) next »