Skip to content
Browse files

Fixing array_change_key_case errors.

- Function present in version PHP 4 >= 4.2.0, PHP 5
  • Loading branch information...
1 parent a705afc commit 57a1c1af6af5f661090c05908df47291b4510b39 julmis committed Sep 2, 2005
Showing with 43 additions and 10 deletions.
  1. +43 −10 lib/magpie/rss_utils.inc
View
53 lib/magpie/rss_utils.inc
@@ -23,38 +23,38 @@
\*======================================================================*/
function parse_w3cdtf ( $date_str ) {
-
+
# regex to match wc3dtf
$pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
-
+
if ( preg_match( $pat, $date_str, $match ) ) {
- list( $year, $month, $day, $hours, $minutes, $seconds) =
+ list( $year, $month, $day, $hours, $minutes, $seconds) =
array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
-
+
# calc epoch for current date assuming GMT
$epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
-
+
$offset = 0;
if ( $match[10] == 'Z' ) {
# zulu time, aka GMT
}
else {
list( $tz_mod, $tz_hour, $tz_min ) =
array( $match[8], $match[9], $match[10]);
-
+
# zero out the variables
if ( ! $tz_hour ) { $tz_hour = 0; }
if ( ! $tz_min ) { $tz_min = 0; }
-
+
$offset_secs = (($tz_hour*60)+$tz_min)*60;
-
+
# is timezone ahead of GMT? then subtract offset
#
if ( $tz_mod == '+' ) {
$offset_secs = $offset_secs * -1;
}
-
- $offset = $offset_secs;
+
+ $offset = $offset_secs;
}
$epoch = $epoch + $offset;
return $epoch;
@@ -64,4 +64,37 @@ function parse_w3cdtf ( $date_str ) {
}
}
+ if (! function_exists('array_change_key_case') ) {
+
+ function array_change_key_case($input, $case=0) {
+
+ if (! is_array($input) ) {
+ return $input;
+ }
+
+ switch ($case) {
+ case 'CASE_UPPER':
+ case 1:
+ $func = 'strtoupper';
+ break;
+ default:
+ $func = 'strtolower';
+ }
+
+ $tmp = array();
+ foreach ($input as $key => $value) {
+
+ if ( is_array($value) ) {
+ $value = array_change_key_case($value, $case);
+ }
+
+ $tmp[$func($key)] = $value;
+ }
+
+ unset($input);
+ return $tmp;
+
+ }
+
+ }
?>

0 comments on commit 57a1c1a

Please sign in to comment.
Something went wrong with that request. Please try again.