Ejemplo n.º 1
0
 public static function _http_build_query($data, $prefix = null, $sep = null, $key = '', $urlencode = true)
 {
     $ret = array();
     foreach ((array) $data as $k => $v) {
         if ($urlencode) {
             $k = urlencode($k);
         }
         if (is_int($k) && $prefix != null) {
             $k = $prefix . $k;
         }
         if (!empty($key)) {
             $k = $key . '%5B' . $k . '%5D';
         }
         if ($v === NULL) {
             continue;
         } elseif ($v === FALSE) {
             $v = '0';
         }
         if (is_array($v) || is_object($v)) {
             array_push($ret, JHotelUtil::_http_build_query($v, '', $sep, $k, $urlencode));
         } elseif ($urlencode) {
             array_push($ret, $k . '=' . urlencode($v));
         } else {
             array_push($ret, $k . '=' . $v);
         }
     }
     if (NULL === $sep) {
         $sep = "|";
     }
     return implode($sep, $ret);
 }
Ejemplo n.º 2
0
 /**
  * Create an piped string for the specified data array
  * 
  * @param array $data
  * @return string
  */
 public static function createPipedString(array $data)
 {
     /*
     $pairs = array();
     
     foreach($data as $key => $value) {
     	if(!empty($value)) {
     		$pairs[] = $key . '=' . $value;
     	}
     }
     
     $pipedString = implode('|', $pairs);
     
     return $pipedString;
     */
     // @see http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/functions.php#L1385
     return JHotelUtil::_http_build_query($data, null, '|', '', false);
 }