When creating regular expressions for PHP I tend to use the awesome tool PHP Live Regex.
This tool has really helped me over the last couple of years to create regular expressions for many of the projects I've been working on. Everything from validation functions to formatters that use regular expressions have had their expressions worked out using this tool. I even use it for testing one off expressions where I just need to find/replace in a file.
PHP Live Regex works by posting the regular expression and your entered data to a PHP server that sends back the result of the regular expression. This is the reason why it is accurate to work out PHP based regular expressions using this tool. I have never had to translate the flags or syntax from this tool into a PHP application. It will also give you PHP code snippets that you can copy and paste into your code.
One word of warning is that it is probably not a good idea to use anything that you wouldn't want to be public on this tool. Due to the fact that the data is sent to an unknown server you have no control over what happens to the data beyond your request. Although the author probably has the best of intentions, the fact that you are transmitting anonymous data means you should only test the output of the tool using test data. So don't go plugging in live credit card details into it!
Since I found the PHP Live Regex tool a couple of years ago it has been a permanent bookmark and I tend to visit it every time I need to work out some complex regular expressions.