Example 1 — Turn Integers into IPv4 Strings
Convert a few well-known integers and print the dotted addresses.
<?php
echo long2ip(2130706433), PHP_EOL;
echo long2ip(134744072), PHP_EOL;
echo long2ip(0), PHP_EOL; How It Works
- 2130706433 maps to 127. 0.0.1.
- 134744072 maps to 8. 8.8.8.
- 0 maps to 0. 0.0.0.
- Each result is a normal string you can echo or store.

