note 126182 added to function.str-replace
| From: | ressing1 at gmail dot com | Date: | Mon, 21 Jun 2021 20:34:20 +0000 |
| Subject: | note 126182 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216534@lists.php.net to get a copy of this message | ||
To remove all characters from string $b that exist in string $a:
$a="ABC";
$b="teAsBtC";
echo str_replace(str_split($a),'',$b);
Output: test
To remove all characters from string $b that don't exist in string $a:
$a="ABC";
$b="teAsBtC";
echo str_replace(str_split(str_replace(str_split($a),'',$b)),'',$b);
Output: ABC
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 66.113.15.212)
----
Manual Page -- https://php.net/manual/en/function.str-replace.php
Edit -- https://main.php.net/note/edit/126182
Del: integrated -- https://main.php.net/note/delete/126182/integrated
Del: useless -- https://main.php.net/note/delete/126182/useless
Del: bad code -- https://main.php.net/note/delete/126182/bad+code
Del: spam -- https://main.php.net/note/delete/126182/spam
Del: non-english -- https://main.php.net/note/delete/126182/non-english
Del: in docs -- https://main.php.net/note/delete/126182/in+docs
Del: other reasons-- https://main.php.net/note/delete/126182
Reject -- https://main.php.net/note/reject/126182
Search -- https://main.php.net/manage/user-notes.php