php file get content replacing & with & 1

php file get content replacing & with &

$myUrl = 'https://www.myurl.com?';
$myArray = [
    'foo' => 'fooString',
    'bar' => 'barString'
];
$myUrl .= http_build_query($myArray,'','&'); // https://www.myurl.com?foo=fooString&bar=barString
$myData = file_get_contents($myUrl);

Here is what the above code is Doing:
1. Create a string with the URL you want to query.
2. Create an array with the data you want to send.
3. Append the data to the URL using http_build_query().
4. Use file_get_contents() to send the data to the URL.

Similar Posts