PHP » PYTHON |
login |
register |
about
|
PYTHON parse_str
is this article helpful?
|
Python replacement for PHP's parse_str
[
edit
| history
]
s = 'first=value&sec=foo+bar' #2.7 import urlparse print urlparse.parse_qs(s) # {'first': ['value'], 'sec': ['foo bar']} # 2.6 import urlparse print urlparse.parse_qs(s) # {'first': 'value', 'sec': 'foo bar'} # 3.x import urllib.parse print urllib.parse.parse_qs(s) # {'first': 'value', 'sec': 'foo bar'} # < 2.6 import cgi print cgi.parse_qs(s) # {'first': 'value', 'sec': 'foo bar'} parse_str(PHP 4, PHP 5) parse_str — Parses the string into variables Description
void parse_str
( string $str
[, array &$arr
] )
Parses str as if it were the query string passed via a URL and sets variables in the current scope.
Parameters
Return ValuesNo value is returned. Changelog
Examples
Example #1 Using parse_str()
<?php
See Also
|
more
Recently updated
more
Most requested
|