PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

http_persistent_handles_clean> <http_parse_message
Last updated: Fri, 14 Nov 2008

view this page in

http_parse_params

(PECL pecl_http:1.0.0-1.5.5)

http_parse_paramsParse parameter list

Description

object http_parse_params ( string $param [, int $flags = HTTP_PARAMS_DEFAULT ] )

Parse parameter list.

See the params parsing constants table for possible values of the flags argument.

Parameters

param

Parameters

flags

Parse flags

Return Values

Returns parameter list as stdClass object.

Examples

Example #1 A http_parse_params() example

<?php
var_dump
(http_parse_params("text/html; charset=\"utf8\""));
?>

The above example will output:

object(stdClass)#1 (1) {
  ["params"]=>
  array(2) {
    [0]=>
    string(9) "text/html"
    [1]=>
    array(1) {
      ["charset"]=>
      string(4) "utf8"
    }
  }
}



add a note add a note User Contributed Notes
http_parse_params
Siegfried Gevatter rainct at ubuntuwire dot com
23-Jun-2007 01:55
I found a little problem on the function I previously posted here, getParser(): PHP replacing all dots in the key with _'s, so following change would be needed to be done in the function:

Replace:
<?PHP
   $gets
[$name] = $value;
?>

With:
<?PHP
   $gets
[str_replace('.', '_', $name)] = urldecode($value);
?>

But actually, arpad (on ##php @ irc.freenode.net) let me notice that it's so, but not if something is between [ and ], so ?var.one[var.two]=hi would become $_GET['var_one[var.two]']. Because of this, as he said, following line should go there instead:

<?PHP
   $gets
[preg_replace("/\.(?=[^\]]*(?:\[|\z))/", '_', $name)] = urldecode($value);
?>
Siegfried Gevatter rainct at ubuntuwire dot com
22-Jun-2007 03:37
<?PHP
/* This simple function gets the query out of a URL, splits it
 * and puts it into an array.
 *
 * For example, "index.php?name=Myself&message=Hello" will
 * become an array looking like this:
 *   array['name'] = 'Myself'
 *   array['message'] = 'Hello'
 */

function getParser($url) {
  
// Extract the query
  
$query = parse_url($url);
  
$query = $query['query'];

  
// Split it
  
$query = explode('&', $query);

  
// Get the elements and put them in an array
     
$gets = array();
      foreach(
$query AS $element) {
         list(
$name, $value) = explode('=', $element, 2);
        
$gets[$name] = $value;
      }

     
// Return the array
     
return $gets;
}

// Example
$_GET = getParser($_SERVER['REQUEST_URI']);

// Let's look what it got
echo '<pre>';
print_r($_GET);
echo
'</pre>';
?>

http_persistent_handles_clean> <http_parse_message
Last updated: Fri, 14 Nov 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites