I've tried multiple ways to format this http string, like escaping the "
that are present in "user"
and the user's name, but the API I'm connecting to will not work with anything but %22
, so:
https://url.com/search/search?p=[{"user":"abc123"}]
has to be formatted like this:
curl_setopt($ch, CURLOPT_URL, 'https://url.com/search/search?p=[{%22user%22:%22abc123%22}]');
into this:
I need to replace %22abc123%22
with the actual user from a PHP variable, so the code looks like this:
[{%22user%22:%22 $phpVariable %22}]');
and is still enclosed in the %22
, but I cannot figure out how to get the variable into the string without causing the string to give me an error. How do I do this (very simple) task?