Edit report at https://bugs.php.net/bug.php?id=60974&edit=1
ID: 60974 Updated by: ras...@php.net Reported by: jonathan at scriptwriterthingy dot com Summary: request for function similar to strpbrk but with replace features -Status: Open +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 Previous Comments: ------------------------------------------------------------------------ [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