wp_parse_str()WP 2.2.1

Parses a string into variables to be stored in an array.

Used By: wp_parse_args()
1 time — 0.000001 sec (speed of light) | 50000 times — 0.07 sec (speed of light) | PHP 7.3.12, WP 5.3.2
Hooks from the function

Return

null. Nothing (null).

Usage

wp_parse_str( $input_string, $result );
$input_string(string) (required)
The string to be parsed.
$result(array) (required) (passed by reference — &)
Variables will be stored in this array.

Examples

0

#1 Demo

Let's break down the query string into array of key => value pairs:

$string = '?one=1&foo=some&two=2&bool=true';

wp_parse_str( $string, $array );

print_r( $array );

/* Will withdraw:

Array
(
	[?one] => 1
	[foo] => some
	[two] => 2
	[bool] => true
)
*/

Changelog

Since 2.2.1 Introduced.

wp_parse_str() code WP 6.4.3

function wp_parse_str( $input_string, &$result ) {
	parse_str( (string) $input_string, $result );

	/**
	 * Filters the array of variables derived from a parsed string.
	 *
	 * @since 2.2.1
	 *
	 * @param array $result The array populated with variables.
	 */
	$result = apply_filters( 'wp_parse_str', $result );
}