I want to remove quotes from my string in curl

Viewed 25

I am getting a token from a website using curl. I got the token almost clean but i cant get the quotes away from my string. This is my code:

curl_setopt($ch, CURLOPT_POSTFIELDS, '');
$card = curl_exec($ch);
$token4 = getStr($card, 'key: ',',affid','');

The result of the string is 'c35372273095b4c5a23939a137317930'

But i want to get the token without the quotes.

1 Answers

You can use trim to remove characters at the beginning and at the end.

Your code should look like this:

curl_setopt($ch, CURLOPT_POSTFIELDS, '');
$card = curl_exec($ch);
$token4 = getStr($card, 'key: ',',affid','');
$token4 = trim($token4, "'"); // removes '
$token4 = trim($token4); // removes all white spaces 
// echo $token4;
Related