在Json Response Body Php之前删除字符串

Hi I am using WHMCS Api I am getting a response in json format like this

string 'userhowhigh83{"result":"success","orderid":787,"productids":"785","addonids":"","domainids":"","invoiceid":"766"}' (length=113)

I am getting the response correctly from API but it is also giving me the string 'userhowhigh83' where 'howhigh83' is the username and 'user' is given static but when I decode the json result it gives me null. I checked in on an online json decoder when I remove 'userhowhigh83' it will works fine.How can I remove this before json response body.

If you cannot get the string in better shape from your API, you always can use substring on your string to get rid of "userhowhigh83" :

$string = substr($string , strpos($string , "{"));

This will do as well:

list($username, $jsonData) = explode('{', $json);
echo '{' . $jsonData;
echo $username;

Another approach will be:

preg_match('/{.*?}/', $json, $matches);
echo $matches[0];