- parse_str: documentation ( source)
- parse_url: documentation ( source)
- http_build_query: documentation ( source)
<?php
$parsed_url = parse_url($url =
"http://en.wikipedia.org/w/api.php?action=query&prop=extracts|info&titles=**VARIABLE**&format=json&explaintext&redirects&inprop=url&indexpageids");
$params = [];
parse_str($parsed_url['query'], $params);
$title = 'Some example';// $data->query->pages->$pageid->title;
$params['titles'] = $title;
$parsed_url['query'] = http_build_query($params);
$url = $parsed_url['scheme'] . '://' . $parsed_url['host'] . $parsed_url['path']. '?' . $parsed_url['query'];
echo $url;