You are here


PHP Regular Expressions – Remove Comments From SQL Text

This short block of PHP code takes a SQL script and removes the “dash-dash” and “/**/” comments from it.  Of course, many languages, including PHP itself, use the “/**/” comment style so this could apply to PHP scripts, as well.

The line that removes the dash-dash style comments could easily be changed to the “//” (slash-slash) style.

Notice the use of percent-signs as delimiters to eliminate the need of escaping forward-slashes.

PHP Date Difference

Finding a quick PHP function for date difference was painful.  Now that I found it, here’s the quick easy way. This site was a great help:

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
1 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer