php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76201 ltrim removes extra char
Submitted: 2018-04-09 10:08 UTC Modified: 2018-04-09 10:20 UTC
From: zewy at hotmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.1.16 OS: CentOs 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zewy at hotmail dot com
New email:
PHP Version: OS:

 

 [2018-04-09 10:08 UTC] zewy at hotmail dot com
Description:
------------
ltrim removes one extra char but only one some chars

Test script:
---------------
<?php

echo ltrim('http://pexample.com','http://');
echo "\r\n";
echo ltrim('http://aexample.com','http://');

Expected result:
----------------
pexample.com
aexample.com

Actual result:
--------------
example.com
aexample.com

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-09 10:20 UTC] pmmaga@php.net
-Status: Open +Status: Not a bug
 [2018-04-09 10:20 UTC] pmmaga@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The second parameter of ltrim() is a list of characters to be trimmed. In your first example, 'p' is one of the characters that will be trimmed, so this is expected.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 11:01:32 2025 UTC