Tag Archive for PHP

Parsing a CSV File in PHP

Ok so it is one of the most common data files in the world: the CSV (Comma Separated Values). So here is all you need in PHP to extract the data from the file. The data is exploded into an array ($data) and can be accessed via the array index. It is simple and very straight forward, no run with…

Resetting an Array Index in PHP

After filtering an array indices are removed from the array resulting in errors while trying to loop over the index. Therefore, one needs to reset then index so that it follows a logical order (1,2,3..) instead of (1,3,6,7…). Luckily, PHP doesn’t have a defined method to do this, but it does have another method that will do this for you…

Using the array_filter function within a class

When using the array_filter method in PHP I attempted to make my callback function a private method within my class. Upon trying to execute my script I recieved an error telling my that I had not defined a proper call back method. After searching for several minutes I came across this snippet of code and I hope it works for you as well.