Replace ereg with preg_match

I was recently developing on a newer version of PHP than what is currently used on most of our servers and I was getting a warning telling me that the function ereg was depreciated.

A little googling told me that is is going to be totally removed from PHP 6 so in the interest of keeping my code nice and up to date I made the following changes....

Use preg_match instead of ereg and wrap the expression with //


Here is an example;

ereg("^[-]?[0-9]+([\.][0-9]+)?$", $var);


preg_match("/^[-]?[0-9]+([\.][0-9]+)?$/", $var);

Recent posts View all

Simple CS


Let's learn about Compilers, what they are and how they work.


Adding an integration to a Slack room

How to add an integration to a Slack room. Part of our Slack mini series.