<?php $names = ['[foo]bar', 'baz', '[blarg]blah']; foreach($names as $name) { preg_match('/^(\[.*?\])?(.*?)$/', $name, $match); var_dump($match[1]); }
You have javascript disabled. You will not be able to edit any code.