PHP One-Liner To Decode JWT (JSON Web Tokens)

Here’s a PHP one-liner to decode a JWT token. I thought of this while working with Google oAuth API which gives back a JWT. I came across this stackoverflow question solving the JavaScript side of things. However a PHP based solution comes in handy for server-side implementation.

print_r(json_decode(base64_decode(str_replace('_', '/', str_replace('-','+',explode('.', $token)[1])))));