2014年9月22日星期一

Sameer Borate: Data cleaning in PHP applications


Sameer Borate has a new post today showing the use of a "cleaner" library to help sanitize the data input to your application. In this tutorial he introduces you to Mr Clean, an "extendible PHP Data Cleaner".



Scrubbers or data cleaners are an important part of the data transformation process. Whenever you are involved in some data import or export process, data scrubbers can help you clean and standardize your data elements before storing. There are many libraries that help in sanitizing and cleaning data. One such I recently found is mr-clean; it is a extendible PHP Data Cleaner that you can use in your PHP applications to clean heterogeneous data before storing it in your database or other persistent storage like CSV files.


He walks you through the installation (via Composer) and the creation of an instance of the main "cleaner" object. He then provides a few examples of some data scrubbing features it offers:



  • Basic scrubbing (trim, stripping HTML tags, etc)
  • Booleans
  • Filtering HTML
  • Stripping CSS attributes
  • Nullify
  • Null if repeated
  • Strip Phone Number
  • Pre/Post scrubbing handling


He finishes up the post with a look at creating a custom scrubber class, an "only numeric" handler that replaces any character that's not a number in a string with an empty string (removing it).


Link: http://www.codediesel.com/data/data-cleaning-in-php-applications/

没有评论:

发表评论