Use preg_replace and regular expressions. The examples below remove everything in a string that is within curly braces or square brackets.

echo preg_replace(" (\[.*?\])",'',"King Kong [2005]");
echo preg_replace(" (\(.*?\))",'',"King Kong (Amazing Box Set)");

How do I remove all characters from within curly brackets or square brackets using PHP

Leave a Reply

Your email address will not be published. Required fields are marked *

eight + one =