#43431 [Fbk->Opn]: Using /H in haystack causes truncated results

From: Date: Sat, 01 Dec 2007 16:53:04 +0000
Subject: #43431 [Fbk->Opn]: Using /H in haystack causes truncated results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120267@lists.php.net to get a copy of this message
ID: 43431 User updated by: lowell at ietech dot com Reported By: lowell at ietech dot com -Status: Feedback +Status: Open Bug Type: Strings related Operating System: Linux data 2.6.18.2-34 PHP Version: 5.2.5 New Comment: Actually, I was looking for a more efficient way to remove the 'leading' string in lieu of ... 'strpos($haystack,$needle)==0?substr($haystack,strlen($needle)):$haystack;' ltrim works great except for this anomaly. I'm quite open to suggestions. I have since created a function to satisfy this, but thought it best to still bring it to your attention. Thanks for your input. Previous Comments: ------------------------------------------------------------------------ [2007-11-28 13:47:35] jani@php.net Are you sure you're using the right function now? string ltrim ( string $str [, string $charlist]) What you think is 'needle' is actually list of characters to remove. It's not str_replace().. ------------------------------------------------------------------------ [2007-11-27 18:51:41] lowell at ietech dot com Description: ------------ Using '/H' (uppercase 'H' is relevant) near the end of the haystack truncates the result (In example below, first 5 letters of 'Health'). Have tried many strings to determine consistency, but have failed. Using '/home' instead of '/Home' in string produced a different result, but any other attempts at increasing or decreasing the # '/H's in the string failed to reveal a consistent behavior. Reproduce code: --------------- $sHayStack = "/data/virtual/abc.com/Home/test/absolute/Health"; $sNeedle = "/data/virtual/abc.com/Home/test/absolute"; echo ltrim( $sHayStack, $sNeedle ); Expected result: ---------------- Health Actual result: -------------- h ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43431&edit=1

« previous php.bugs (#120267) next »