<?php $mainstr = "@@PHP@Programming!!!."; echo "Text before remove: " . $mainstr; echo " Text after remove: " . trim($mainstr, '@!.'); ?>