Changeset 1071

Show
Ignore:
Timestamp:
11/09/2007 09:14:16 PM (11 months ago)
Author:
Shadowhand
Message:

Updated URI::construct() to properly handle arrays in the GET string.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/URI.php

    r1015 r1071  
    2222                        foreach($_GET as $key => $val) 
    2323                        { 
    24                                 self::$query_string .= $key.'='.rawurlencode($val); 
     24                                if (is_array($val)) 
     25                                { 
     26                                        foreach($val as $sub_key => $sub_val) 
     27                                        { 
     28                                                // Integer subkeys are numerically indexed arrays 
     29                                                $sub_key = is_int($sub_key) ? '[]' : '['.$sub_key.']'; 
     30 
     31                                                self::$query_string .= $key.rawurlencode($sub_key).'='.rawurlencode($sub_val).'&'; 
     32                                        } 
     33                                } 
     34                                else 
     35                                { 
     36                                        self::$query_string .= $key.'='.rawurlencode($val).'&'; 
     37                                } 
    2538                        } 
     39 
     40                        // Remove the ending ampersand 
     41                        self::$query_string = rtrim(self::$query_string, '&'); 
    2642                } 
    2743        }