I want to give users some formatting options like Reddit or stackOverFlow do, but want to keep it in PHP. How can parse a string in PHP such that it recognizes patterns like **[anything here]**?
explode() doesn’t seem to solve the problem as elegantly as I’d like. Should I just use nested ifs and fors based on explode()’s output? Is there a better solution here?
This has already been done countless times by others, I’d recommend using existing libraries.
For example, you can use Markdown: http://michelf.com/projects/php-markdown/