# PHP - remove unwanted characters

**URL:** <https://forum.kirupa.com/t/php-remove-unwanted-characters/107957>\
**Category:** Uncategorized\
**Created:** [April 20, 2004, 4:55pm UTC](https://forum.kirupa.com/t/php-remove-unwanted-characters/107957 "2004-04-20T16:55:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![imagined](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@imagined](https://forum.kirupa.com/u/imagined)\
**Post date:** [April 20, 2004, 4:55pm UTC](https://forum.kirupa.com/t/php-remove-unwanted-characters/107957/1 "2004-04-20T16:55:26Z")

</div>

I made this script to remove all spaces and unwanted characters from a file name. I think there should be a way to simplify it. How can I simplify the script. IM SORRY, im new to PHP.

```
$imageFileClean = str_replace(" ", "", $_FILES['imageFile']['name']);
$imageFileClean = str_replace("!", "", $imageFileClean);
$imageFileClean = str_replace("#", "", $imageFileClean);
$imageFileClean = str_replace("$", "", $imageFileClean);
$imageFileClean = str_replace("%", "", $imageFileClean);
$imageFileClean = str_replace("^", "", $imageFileClean);
$imageFileClean = str_replace("&", "", $imageFileClean);
$imageFileClean = str_replace("*", "", $imageFileClean);
$imageFileClean = str_replace("(", "", $imageFileClean);
$imageFileClean = str_replace(")", "", $imageFileClean);
$imageFileClean = str_replace("+", "", $imageFileClean);
$imageFileClean = str_replace("=", "", $imageFileClean);
```
