Get only part of the Cookie string

Asked

Viewed 55 times

1

I have the cookie: twid that is returning like this in the browser.

%22u%3D859186139894337536%22

I’d like to take just this:

859186139894337536

It is possible to do so in PHP.

PS: I’m getting it cookies of Twitter via cURL.

1 answer

2


First you should use the urldecode to remove URL characters from your string.

$var = urldecode("%22u%3D859186139894337536%22");

After that you can use the function filter_var that will filter your string and return what you specify:

$var = filter_var($var, FILTER_SANITIZE_NUMBER_INT);

print_r($var);
  • Man, you’re too... vlw

Browser other questions tagged

You are not signed in. Login or sign up in order to post.