return array_pop($goodmatches);
}
-/**
- * The clone keyword is only supported from PHP 5 onwards.
- * The behaviour of $obj2 = $obj1 differs fundamentally
- * between PHP 4 and PHP 5. In PHP 4 a copy of $obj1 was
- * created, in PHP 5 $obj1 is referenced. To create a copy
- * in PHP 5 the clone keyword was introduced. This function
- * simulates this behaviour for PHP < 5.0.0.
- * See also: http://mjtsai.com/blog/2004/07/15/php-5-object-references/
- *
- * Modified 2005-09-29 by Eloy (from Julian Sedding proposal)
- * Found a better implementation (more checks and possibilities) from PEAR:
- * http://cvs.php.net/co.php/pear/PHP_Compat/Compat/Function/clone.php
- *
- * @param object $obj
- * @return object
- */
-if(!check_php_version('5.0.0')) {
-// the eval is needed to prevent PHP 5 from getting a parse error!
-eval('
- function clone($obj) {
- /// Sanity check
- if (!is_object($obj)) {
- user_error(\'clone() __clone method called on non-object\', E_USER_WARNING);
- return;
- }
-
- /// Use serialize/unserialize trick to deep copy the object
- $obj = unserialize(serialize($obj));
-
- /// If there is a __clone method call it on the "new" class
- if (method_exists($obj, \'__clone\')) {
- $obj->__clone();
- }
-
- return $obj;
- }
-
- // Supply the PHP5 function scandir() to older versions.
- function scandir($directory) {
- $files = array();
- if ($dh = opendir($directory)) {
- while (($file = readdir($dh)) !== false) {
- $files[] = $file;
- }
- closedir($dh);
- }
- return $files;
- }
-
- // Supply the PHP5 function array_combine() to older versions.
- function array_combine($keys, $values) {
- if (!is_array($keys) || !is_array($values) || count($keys) != count($values)) {
- return false;
- }
- reset($values);
- $result = array();
- foreach ($keys as $key) {
- $result[$key] = current($values);
- next($values);
- }
- return $result;
- }
-');
-}
-
/**
* This function will make a complete copy of anything it's given,
* regardless of whether it's an object or not.