pull-icon
logo-mobile

Badword Filter

Home/Forums/Badword Filter

Bronze Member
Bronze Member

EmmaS

two months ago

Replace unwanted words with preferred alternatives.

<?php
declare(strict_types=1);

/**
 *
 * Features:
 * - Case-insensitive matching
 * - Easy to extend (just edit the $replacements array)
 * - Safe for any input (typed and validated)
 */
function cleanText(string $text): string
{
    $replacements = [
        'asshole' => 'mate',
        'arse'   => 'bottom',
    ];

    return str_ireplace(
        array_keys($replacements),
        array_values($replacements),
        $text
    );
}

// Example
$original = "Oi asshole, Im gonna kick your arse on COD!";
$cleaned  = cleanText($original);

echo $cleaned;


Result = Oi mate, Im gonna kick your bottom on COD!

Leave a Comment

You must be logged in to post a reply.

Thank you ??

Thanks for supporting this station!

We've sent a download link to your email {}
Please check your inbox (and spam folder just in case).
The link will be valid for 24 hours.



BellOnline offers fast, reliable UK hosting with strong security and excellent uptime - perfect for modern radio and web projects.
MixStream provides broadcast-grade streaming with crystal-clear audio and rock-solid stability, ideal for both hobby and professional stations.

Goto BellOnline Now!

Close