Home > Programming > My own PHP Extension Released – several time savers.

My own PHP Extension Released – several time savers.

August 14th, 2011 Leave a comment Go to comments

This weekend I’ve finished off my first public PHP extension using the (god awful) Zend PHP macro’s, function calls etc. There were 3 reasons for me doing this:

1) See how difficult it was
2) Create a true library for PHP projects to reduce code repetition across projects.
3) Add some speed to projects that crunch a lot of data in PHP.

The extension I’ve released adds the following functions:

/**
* Given a multi line input, removes empty lines and whitespace at the ^ and $ of each line.
* Remove duplicate lines by setting the second param to true.
* Naturally case insensitive sort by setting the third param to true.
*
* @param string $string string to trim.
* @param boolean $unique strip duplicate lines [default: false]
* @param boolean $sort sort returned lines [default: false]
*
* @return string
*/

function wadew_multiline_trim($string, $unique = false, $sort = false){}

/**
* Converts catchable errors to ErrorException objects.
*
* @return void
*/

function wadew_register_error_exception_handler(){}

/**
* Checks all elements of an array to ensure they're all of the required type.
*
* @param array $elements array of objects to check
* @param string $class name of class to match against.
*
* @return boolean
*/

function wadew_array_instanceof(array $elements, $class){}

/**
* Converts a string to its binary MD5 equivalent.
* Same output as md5("string", true) - just faster!
*
* @param string $string string to convert to MD5
*
* @return string
*/

function wadew_md5bin($string){}

/**
* Returns an array of strings by casting to string or calling magic __toString()
*
* @param array $elements elements to convert
*
* @return array
*/

function wadew_array_tostring(array $elements){}

You can get it from https://github.com/wadewomersley/wadew_php_extending


Related posts:

  1. Regular Expression (Regex) For Date part extraction/array split
  2. Automating “Implemented methods” for a web based API
  3. F**k it – N(really)SFW
  4. FFXIV – Final Fantasy 14 – TGS Trailer

Categories: Programming Tags:
  1. No comments yet.
  1. No trackbacks yet.

Easy AdSense by Unreal