WebjxCom提示:本文是整理的学习
PHP的部分中文函数.
函数uasort()
描述:
以自定义的方式排列一个数组且序列不变
。 函数uksort()
描述:
以自定义的方式以key排列
Thisfunctionwillsortthekeysofanarrayusingauser-suppliedcomparisonfunction.Ifthearrayyouwishtosortneedstobesortedbysomenon-trivialcriteria,youshouldusethisfunction.Example1.uksort()example
functionmycompare($a,$b){
if($a==$b)return0;
return($a>$b)?-1:1;
}
$a=array(4=>"four",3=>"three",20=>"twenty",10=>"ten");
uksort($a,mycompare);
while(list($key,$value)=each($a)){
echo"$key:$value
";
}
Thisexamplewoulddisplay:20:twenty10:ten4:four3:three
函数usort()
描述:
以自定义的方式以value排列
voidusort(arrayarray,functioncmp_function);
Thisfunctionwillsortanarraybyitsvaluesusingauser-suppliedcomparisonfunction.Ifthearrayyouwishtosortneedstobesortedbysomenon-trivialcriteria,youshouldusethisfunction.Example1.usort()example
functioncmp($a,$b){
if($a==$b)return0;
return($a>$b)?-1:1;
}
$a=array(3,2,5,6,1);
usort($a,cmp);
while(list($key,$value)=each($a)){
echo"$key:$value
";
}
Thisexamplewoulddisplay:0:61:52:33:24:1Obviouslyinthistrivialcasethersort()functionwouldbemoreappropriate.
BC(ArbitraryPrecision)Functions
函数bcadd()
描述:
Addtwoarbitraryprecisionnumbers
stringbcadd(stringleftoperand,stringrightoperand,int[scale]);左面的字符加右面的字符
,返回一个字符
。 函数bccomp()
描述:
intbccomp(stringleftoperand,stringrightoperand,int[scale]);
左面的字符和右面的字符进行比较
,如果相等的话返回0,如果左面的比右面的长返回+1,右面的比左面的长返回-1
函数bcdiv()
描述:
Dividetwoarbitraryprecisionnumbers
stringbcdiv(stringleftoperand,stringrightoperand,int[scale]);将左面的字符串以右面的字符串为标准分开
函数bcmod()
描述:
Getmodulusofanarbitraryprecisionnumber
stringbcmod(stringleftoperand,stringmodulus);
用右面的modulus操作左面的字符串
函数bcmul()
描述:
Multiplytwoarbitraryprecisionnumber
stringbcmul(stringleftoperand,stringrightoperand,int[scale]);
Multiplytheleftoperandbytherightoperandandreturnstheresult.Theoptionalscalesetsthenumberofdigits
afterthedecimalplaceintheresult.
函数bcpow()
描述:
Raiseanarbitraryprecisionnumbertoanother.
Raisextothepowery.Thescalecanbeusedtosetthenumberofdigitsafterthedecimalplaceintheresult.
函数bcscale()
描述:
Setdefaultscaleparameterforallbcmathfunctions.
stringbcscale(intscale);
Thisfunctionsetsthedefaultscaleparameterforallsubsequentbcmathfunctionsthatdonotexplicitlyspecifyascale
parameter
函数bcsqrt()
描述;
stringbcsqrt(stringoperand,intscale);
返回字符的平方根
函数bcsub()
描述:
stringbcsub(stringleftoperand,stringrightoperand,int[scale]);
将右面的字符减去左面的字符
CalendarFunctions日历功能
函数JDToGregorian()
描述:
stringjdtogregorian(intjulianday);
将Julian日历转换成Gregorian日历
函数GregorianToJD()
描述:
intgregoriantojd(intmonth,intday,intyear);
将Gregorian日历转换成Julian日历
函数JDToJulian()
描述:
stringjdtojulian(intjulianday);
将JulianCalendar转换JulianDay
函数JulianToJD()
描述:
intjuliantojd(intmonth,intday,intyear);
函数JDToJewish()
描述:
ConvertsaJulianDayCounttotheJewishCalendar
stringjdtojewish(intjulianday);
函数JewishToJD()
描述:
ConvertsadateintheJewishCalendartoJulianDayCount
intjewishtojd(intmonth,intday,intyear);
函数JDToFrench()
描述:
ConvertsaJulianDayCounttotheFrenchRepublicanCalendar
stringjdtofrench(intmonth,intday,intyear);
函数FrenchToJD()
描述:
ConvertsadatefromtheFrenchRepublicanCalendartoaJulianDayCountintfrenchtojd(intmonth,intday,intyear);
函数JDMonthName()
描述:
Returnsamonthname
stringjdmonthname(intjulianday,intmode);
ModeMeaning
0Gregorian-apreviated
1Gregorian
2Julian-apreviated
3Julian
4Jewish
5FrenchRepublican
函数JDDayOfWeek()
描述:
Returnsthedayoftheweek
mixedjddayofweek(intjulianday,intmode);
ModeMeaning
0returnsthedaynumberasanint(0=sunday,1=monday,etc)
1returnsstringcontainingthedayofweek(english-gregorian)
2returnsastringcontainingtheabreviateddayofweek(english-gregorian)