From 406bfe55294bf20fc7a69a57ffb929adb856eb05 Mon Sep 17 00:00:00 2001 From: skeeter Date: Fri, 17 Aug 2001 19:34:48 +0000 Subject: [PATCH] Added 2 new support functions. array_search() and in_array(). --- phpgwapi/inc/php3_support_functions.inc.php | 43 ++++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/phpgwapi/inc/php3_support_functions.inc.php b/phpgwapi/inc/php3_support_functions.inc.php index a3295b7267..3539a346a6 100755 --- a/phpgwapi/inc/php3_support_functions.inc.php +++ b/phpgwapi/inc/php3_support_functions.inc.php @@ -3,7 +3,7 @@ /**************************************************************************\ * phpGroupWare API - PHP3 Compatibility layer * * This file written by Dan Kuykendall * - * Has repliations of PHP4 only functions to allow for transparent PHP3 * + * Has replications of PHP4 only functions to allow for transparent PHP3 * * compatibility * * Copyright (C) 2000, 2001 Dan Kuykendall * * -------------------------------------------------------------------------* @@ -43,4 +43,43 @@ return False ; } } -?> \ No newline at end of file + +/* + function array_reverse ($array, $preserve_keys = FALSE) + { + for(list($key,$value) = @end($array); list($key,$value) = @prev($array); ) + { + $temp_array[$key] = $value; + } + return $temp_array; + } +*/ + + function array_search ($needle, $haystack, $strict = FALSE) + { + @reset($haystack); + while(list($key,$value) = each($haystack)) + { + if ($haystack[$key]==$needle && (!$strict || gettype($haystack[$key]==gettype($needle))) + { + return $key; + } + } + return FALSE; + } + + function in_array ($needle, $haystack, $strict = FALSE) + { + if(is_array ($haystack) && count($haystack)) + { + for(@reset($haystack); $x=each($haystack); ) + { + if($needle==$x[1] && (!$strict || gettype($needle)==gettype($x[1]))) + { + return TRUE; + } + } + return FALSE; + } + } +?>