How to find both IPv6 and IPv4 with PHP?

When I look up my ip address on a website, it offers both my IPv6 and IPv4 address. When I use a PHP-script it only return the IPv6 address (both $_SERVER[‘REMOTE_ADDR’] and getenv(‘REMOTE_ADDR’)).

How do these websites get my IPv4 address?

I have looked into all the $_SERVER variables but cannot find it.