urldecode()
urldecode() — Decodes URL-encoded string.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character.
Signature
urldecode(string $string): string
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $string | string | The string to be decoded. |
Return value
Returns the decoded string.
Example
A runnable snippet:
$query = "my=apples&are=green+and+red"; foreach (explode('&', $query) as $chunk) { $param = explode("=", $chunk); if ($param) { printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1])); } }
See also
urlencode(), rawurlencode(), rawurldecode()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page urldecode() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.