Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

parse_str()

Parse a URL query into the required output variable using form decoding.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

parse_str(string $string, &$result): void

Parse a URL query into the required output variable using form decoding. Bracketed names build arrays. Duplicate plain keys overwrite earlier values, and spaces or periods in top-level names become underscores. The result is limited by PHP’s max_input_vars setting.

Signature

parse_str(string $string, &$result): void

Example output

{"a_b":"x y","tag":["a","b"],"n":"2"}

Examples

<?php
$data = [];
parse_str("a.b=x+y&tag[]=a&tag[]=b&n=1&n=2",$data);
echo json_encode($data);

Result

{"a_b":"x y","tag":["a","b"],"n":"2"}

Sources