HomePHP Working with Regular Expressions with Filters in PHP 5
Working with Regular Expressions with Filters in PHP 5
Among the enhancements that were introduced originally in PHP 5, there’s one powerful extension that has been all but ignored by many programmers until now, quite possibly because they weren’t aware of its existence. Yes, as you might have guessed, I’m talking about the filter library -- a handy set of filters and functions that allow you to validate different types of data with remarkable ease.
Thus, if you’re interested in learning how to put this group of filters to work for you in a very short time, begin reading this series of articles, since in it you’ll find the right pointers to get you started using the filter library in a true painless fashion.
However, if you already had the opportunity to read all of the preceding chapters of this series, it’s possible that you now have a pretty solid background in utilizing this extension. In those tutorials I used several hands-on examples to explain how to validate integers and float numbers, and to check Boolean values by means of a couple of intuitive PHP functions and simple constants.
Now, speaking more specifically, in the previous article I explained how to use the “filter_var()” function in conjunction with the FILTER_VALIDATE_FLOAT filter to validate floating numbers assigned to a single scalar variable and stored in arrays, which speaks for itself about the versatility of the filter in question.
Nonetheless, this instructive journey on which we're exploring the capabilities offered by the filter extension doesn’t stop there. In this fifth part of the series, I’m going to discuss the usage of the extension for checking if the value that has been assigned to a given variable follows a specified regular expression pattern.
That sounds pretty interesting, right? Therefore, if I've caught your attention, then it’s time to continue discovering many other handy validation features provided by the PHP 5 filter library. Let’s get going!