><?php > >// VFP's (Visual FoxPro) SYS2015() for PHP. >// >// Generates a unique key that's compatible with VFP. Written >// for backward compatibility for those who need to generate >// VFP keys. >// We wrote this code and decided to post it just incase anyone >// else out there has to import/export tables back and forth >// between VFP and some other RDBMS. >// >// Based on the VFP code from convertdatetime.prg, which is >// located at levelextreme.com's VFP download area as >// convert2015.zip (File #9704). >// >// Enjoy! >// >// Code released into the public domain for the VFP community. > >FUNCTION SYS2015() >{ > $cBase36="0123456789ABCDEFGHIJKLMONPQRSTUVWXYZ"; > $cSys2015=""; > $hour=(int)date("H"); > $nmilli=($hour*3600 + (int)date("i")*60+(int)date("s"))*1000; > $year=date("Y"); > $t=mktime(0,0,0,1,1,$year); > $days = (int)((time(void)-mktime(0,0,0,1,1,$year))/86400)+ ($year%100)*367; > > > for ($counter=1;$counter<7;$counter++) > { > $cSys2015=substr($cBase36,(int)($nmilli % 36) +1,1) . $cSys2015; > $nmilli=(int)($nmilli/36); > } > > for ($counter=1;$counter<4;$counter++) > { > $cSys2015=substr($cBase36,($days%36) +1,1) . $cSys2015; > $days=(int)($days/36); > } > > $cSys2015="_".$cSys2015; > > return $cSys2015; > >} > >?> > >