International PHP Conference Munich 2025

Voting

: two minus one?
(Example: nine)

The Note You're Voting On

ressing1 at gmail dot com
3 years ago
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

<< Back to user notes page

To Top