{ Snipperize } /PHP

PHP snippets

Here are the latest PHP snippets. Please choose your favorite one or add a new one.

Is Local Address

Checks if a given address is local. Useful for setting up the dev environment automatically. NOTE: It's not intended for validation!

PHP / detector, local, address, preg_match / by ThePeppersStudio (58 days, 15.12 hours ago)

Compressing Strings

When talking about compression, we usually think about files, such as ZIP archives. It is possible to compress long strings in PHP, without involving any archive files. We were able to achive almost 50% size reduction. Also the functions gzencode() and gzdecode() achive similar results, by using a different compression algorithm.

PHP / string, compress, gzip, gzencode, gzdecode, gzcompress, gzuncompress / by ThePeppersStudio (105 days, 12.08 hours ago)

Functions with Arbitrary Number of Arguments

You may already know that PHP allows you to define functions with optional arguments. But there is also a method for allowing completely arbitrary number of function arguments.

PHP / argument, function, arbitrary, func_get_args / by ThePeppersStudio (105 days, 12.13 hours ago)

PHP Excel Reader

PHP Excel Reader allows you to parse and retrieve information from XLS files. It reads the binary format of XLS files directly and can return values and formats from any cell.

PHP / excel, parser, reader, xls / by ThePeppersStudio (126 days, 13.44 hours ago)

Date and Time Difference Calculate in PHP

Calculate date time difference.

PHP / date, time, calculate / by ThePeppersStudio (169 days, 12.58 hours ago)

Kohana System Configuration Hook

Instead of having multiple configurations for multiple domains, and the numerous if/then/else statements not to mention the various locations for storing the configuration....instead, enable hooks in your application config and then add this snippet of code into your application hooks directory.

PHP / php, kohana, system, configuration, hook / by ThePeppersStudio (173 days, 6.27 hours ago)

How to read ID3 tag of mp3 files with PHP

Inside mp3 files there are often some usefull informations stored. Those data are called “id3 tags” and deal with Author name, Title and Album name. There are also some other informations sometimes: such as the length of the track, or the track number of the album, and more, this code will help read those files!

PHP / mp3, id3, meta / by ThePeppersStudio (192 days, 12.80 hours ago)

Redirect Domain Including Subdomains and Arguments

I used this as an include on every page to redirect every page incl arguments from .com to .de

PHP / redirect, subdomain, domain / by ThePeppersStudio (195 days, 8.95 hours ago)

PHP Contextual Dates

friendly contextual dates

PHP / contextual, date, friendly / by ThePeppersStudio (218 days, 7.05 hours ago)

Convert String To ASCII

避免多语言编码问题

PHP / convert, string, ascii / by ThePeppersStudio (280 days, 9.00 hours ago)