My own PHP Extension Released – several time savers.
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: