[ipv6-ops] A postgresql & php inet to ip6.arpa snippet

Sam Wilson Sam.Wilson at ed.ac.uk
Tue Jul 26 11:38:15 CEST 2011


On 26 Jul 2011, at 01:22, Aaron Hughes wrote:

>     /* Pad each segment until it has 4 digits */
>     foreach ($part as &$p) {
>         while (strlen($p) < 4) $p = '0' . $p;
>     } // foreach

Pardon me while I delurk.  perl is my language of choice, and I've  
never written PHP in anger, but surely the above would be better as  
something like this:

     /* Pad each segment until it has 4 digits */
     foreach ($part as &$p) {
         $p = substr("0000".$p, -4, 4);   /* not sure if that -4 is  
right */
     } // foreach

Sam

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the ipv6-ops mailing list