[PHP-BUG] Req #60974 [NEW]: request for function similar to strpbrk but with replace features
From: Operating system: Linux/CentOS PHP version: Irrelevant Package: *General Issues Bug Type: Feature/Change Request Bug description:request for function similar to strpbrk but with replace features Description: --- >From manual page: http://www.php.net/function.strpbrk --- This is a great function I wasn't aware of until recently. I love that it can find any character from a list of characters - very useful for filtering data. Would be even better if there were a similar function that replaced any matched character listed in the input string with: 1) a single specified character, 2) a character from a list/string of characters (similar to what you do with str_replace but without the need for arrays) 3) a random character from the supplied list of characters mentioned in item 2. #1 on that list is the most important of my request. #2 and 3 would be nice to have but I can live without as str_replace already does some of this but requires arrays. Test script: --- Partial demo of concept $char_list = "-!@#$%^&*()+=-/?.>,<;:"; //characters we want to remove $input_string = "Some data that's not supposed to have $puncuation!"; $replace_string = ''; $result_string = strpbrk_replace($input_string, $char_list, $replace_string); Expected result: And hopefully the result string looks like this: "Some data that's not supposed to have puncuation" Or if $replace_string had = ' '; "Some data that's not supposed to have puncuation " Actual result: -- See above... -- Edit bug report at https://bugs.php.net/bug.php?id=60974&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60974&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60974&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60974&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60974&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60974&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60974&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60974&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60974&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60974&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60974&r=support Expected behavior: https://bugs.php.net/fix.php?id=60974&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60974&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60974&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60974&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60974&r=php4 Daylight Savings:https://bugs.php.net/fix.php?id=60974&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60974&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60974&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60974&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60974&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60974&r=mysqlcfg
Req #60974 [Ana]: request for function similar to strpbrk but with replace features
Edit report at https://bugs.php.net/bug.php?id=60974&edit=1 ID: 60974 User updated by:jonathan at scriptwriterthingy dot com Reported by:jonathan at scriptwriterthingy dot com Summary:request for function similar to strpbrk but with replace features Status: Analyzed Type: Feature/Change Request Package:*General Issues Operating System: Linux/CentOS PHP Version:Irrelevant Block user comment: N Private report: N New Comment: "This sounds like strtr() to me" According to the php docs strstr says it "Returns part of haystack string from the first occurrence of needle to the end of haystack." - it doesn't say anything about replacing characters which is the main difference between my request and the current strpbrk() function. My request does have some similarities to str_replace() as mentioned above but would do so strings instead of arrays. Previous Comments: [2012-02-03 20:28:06] ras...@php.net This sounds like strtr() to me ---- [2012-02-03 20:21:05] jonathan at scriptwriterthingy dot com Description: --- >From manual page: http://www.php.net/function.strpbrk --- This is a great function I wasn't aware of until recently. I love that it can find any character from a list of characters - very useful for filtering data. Would be even better if there were a similar function that replaced any matched character listed in the input string with: 1) a single specified character, 2) a character from a list/string of characters (similar to what you do with str_replace but without the need for arrays) 3) a random character from the supplied list of characters mentioned in item 2. #1 on that list is the most important of my request. #2 and 3 would be nice to have but I can live without as str_replace already does some of this but requires arrays. Test script: --- Partial demo of concept $char_list = "-!@#$%^&*()+=-/?.>,<;:"; //characters we want to remove $input_string = "Some data that's not supposed to have $puncuation!"; $replace_string = ''; $result_string = strpbrk_replace($input_string, $char_list, $replace_string); Expected result: And hopefully the result string looks like this: "Some data that's not supposed to have puncuation" Or if $replace_string had = ' '; "Some data that's not supposed to have puncuation " Actual result: -- See above... -- Edit this bug report at https://bugs.php.net/bug.php?id=60974&edit=1
[PHP-BUG] Req #60975 [NEW]: case insensitive implementation of strpbrk
From: Operating system: Linux/CentOS PHP version: Irrelevant Package: *General Issues Bug Type: Feature/Change Request Bug description:case insensitive implementation of strpbrk Description: strpbrk() is case sensitive. It would be great to see a case insensitive implementation - stripbrk() -- Edit bug report at https://bugs.php.net/bug.php?id=60975&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60975&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60975&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60975&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60975&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60975&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60975&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60975&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60975&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60975&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60975&r=support Expected behavior: https://bugs.php.net/fix.php?id=60975&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60975&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60975&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60975&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60975&r=php4 Daylight Savings:https://bugs.php.net/fix.php?id=60975&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60975&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60975&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60975&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60975&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60975&r=mysqlcfg
Req #60974 [Ana->Csd]: request for function similar to strpbrk but with replace features
Edit report at https://bugs.php.net/bug.php?id=60974&edit=1 ID: 60974 User updated by:jonathan at scriptwriterthingy dot com Reported by:jonathan at scriptwriterthingy dot com Summary:request for function similar to strpbrk but with replace features -Status: Analyzed +Status: Closed Type: Feature/Change Request Package:*General Issues Operating System: Linux/CentOS PHP Version:Irrelevant Block user comment: N Private report: N New Comment: Ah, somehow I missed that. Thanks, I think that's pretty much what I was hoping for. Previous Comments: [2012-02-03 21:05:10] ras...@php.net I said strtr() not strstr() [2012-02-03 20:45:09] jonathan at scriptwriterthingy dot com "This sounds like strtr() to me" According to the php docs strstr says it "Returns part of haystack string from the first occurrence of needle to the end of haystack." - it doesn't say anything about replacing characters which is the main difference between my request and the current strpbrk() function. My request does have some similarities to str_replace() as mentioned above but would do so strings instead of arrays. [2012-02-03 20:28:06] ras...@php.net This sounds like strtr() to me ---- [2012-02-03 20:21:05] jonathan at scriptwriterthingy dot com Description: --- >From manual page: http://www.php.net/function.strpbrk --- This is a great function I wasn't aware of until recently. I love that it can find any character from a list of characters - very useful for filtering data. Would be even better if there were a similar function that replaced any matched character listed in the input string with: 1) a single specified character, 2) a character from a list/string of characters (similar to what you do with str_replace but without the need for arrays) 3) a random character from the supplied list of characters mentioned in item 2. #1 on that list is the most important of my request. #2 and 3 would be nice to have but I can live without as str_replace already does some of this but requires arrays. Test script: --- Partial demo of concept $char_list = "-!@#$%^&*()+=-/?.>,<;:"; //characters we want to remove $input_string = "Some data that's not supposed to have $puncuation!"; $replace_string = ''; $result_string = strpbrk_replace($input_string, $char_list, $replace_string); Expected result: And hopefully the result string looks like this: "Some data that's not supposed to have puncuation" Or if $replace_string had = ' '; "Some data that's not supposed to have puncuation " Actual result: -- See above... -- Edit this bug report at https://bugs.php.net/bug.php?id=60974&edit=1