The user asked for something simple, so I gave him something simple.
$input = "[link=http://www.google.com]test[/link]";
$replacement = preg_replace('/\[link=(.*?)\](.*?)\[\/link\]/', '<a href="https://stackoverflow.com/questions/10458103/">$2</a>', $input);
Where /\[link=(.*?)\](.*?)\[\/link\]/
is the regex, <a href="https://stackoverflow.com/questions/10458103/">$2</a>
is the format, $input
is the input/data, and $replacement
is the return.
1
solved How to make PHP BB Codes with RegExp?