学习:PHP中文函数(2)_PHP技巧_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

学习:PHP中文函数(2)

作者:黑客防线网安PHP教程基地 来源:黑客防线网安PHP教程基地 浏览次数:0

本篇关键词:函数中文学习fruits
黑客防线网安网讯:  函数count()    描述:    计算一变量中元素的个数    intcount(mixedvar);    Returnsthenumberofelementsinvar,whichistypicallyanarray(sinceanythingelsewillhaveo...
  函数count()
  
  描述:
  
  计算一变量中元素的个数
  
  intcount(mixedvar);
  
  Returnsthenumberofelementsinvar,whichistypicallyanarray(sinceanythingelsewillhaveoneelement).
  
  Returns0ifthevariableisnotset.
  
  Returns1ifthevariableisnotanarray.
  
  函数current()
  
  描述:
  
  传回数组指针目前所指的元素
  
  mixedcurrent(arrayarray);
  
  Eacharrayvariablehasaninternalpointerthatpointstooneofitselements.Inaddition,alloftheelementsinthearrayarelinkedbyabidirectionallinkedlistfortraversingpurposes.Theinternalpointerpointstothefirstelementthatwasinsertedtothearrayuntilyourunoneofthefunctionsthatmodifythatpointeronthatarray.
  
  Thecurrent()functionsimplyreturnsthearrayelementthat'scurrentlybeingpointedbytheinternalpointer.Itdoesnotmovethepointerinanyway.Iftheinternalpointerpointsbeyondtheendoftheelementslist,current()returnsfalse.
  
  函数each()
  
  描述:
  
  返回数组中下一对key/value的值
  
  arrayeach(arrayarray);
  
  Returnsthecurrentkey/valuepairfromthearrayarrayandadvancesthearraycursor.Thispairisreturnedinafour-elementarray,withthekeys0,1,key,andvalue.Elements0andkeyeachcontainthekeynameofthearrayelement,and1andvaluecontainthedata.
  
  Example1.each()examples
  
  $foo=array("bob","fred","jussi","jouni");$bar=each($foo);
  
  $barnowcontainsthefollowingkey/valuepairs:
  
  0=>0
  
  1=>'bob'
  
  key=>0
  
  value=>'bob'
  
  $foo=array("Robert"=>"Bob","Seppo"=>"Sepi");$bar=each($foo);
  
  $barnowcontainsthefollowingkey/valuepairs:
  
  0=>'Robert'
  
  1=>'Bob'
  
  key=>'Robert'
  
  value=>'Bob'
  
  Example2.Traversing$HTTP_POST_VARSwitheach()
  
  echo"ValuessubmittedviaPOSTmethod:<br>";
  
  while(list($key,$val)=each($HTTP_POST_VARS)){
  
  echo"$key=>$val<br>";
  
  }
  
  函数end()
  
  描述:
  
  将数组中的指针移到最后一个
  
  end(arrayarray);
  
  end()advancesarray'sinternalpointertothelastelement.
  
  函数key()
  
  描述:
  
  从一数组中取出key
  
  mixedkey(arrayarray);
  
  key()returnstheindexelementofthecurrentarrayposition.
  
  函数ksort()
  
  描述:
  
  以key来排列一数组
  
  Example1.ksort()example
  
  $fruits=array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");
  
  ksort($fruits);
  
  for(reset($fruits);
  
  $key=key($fruits);
  
  next($fruits)){echo"fruits[$key]=".$fruits[$key]." ";}
  
  Thisexamplewoulddisplay:fruits[a]=orangefruits[b]=bananafruits[c]=applefruits[d]=lemon
  
  函数list()
  
  描述:
  
  用类似数组的方式去指定一整串变量的值
  
  Example1.list()example
  
  <table><tr><th>Employeename</th>
  
  <th>Salary</th></tr>
  
  <?php$result=mysql($conn,"SELECTid,name,salaryFROMemployees");
  
  while(list($id,$name,$salary)=mysql_fetch_row($result)){
  
  print("<tr> "."<td><ahref="info.php3?id=$id">$name</a></td> "."<td>$salary</td> "."</tr> ");
  
  }
  
  ?>
  
  </table>
  
  函数next()
  
  描述:
  
  将数组的指向指到下一组数据
  
  函数pos()
  
  描述:
  
  传回数组的当前的数据
  
  函数prev()
  
  描述:
  
  传回数组的前一条的数据
  
  函数reset()
  
  描述:
  
  数组的指针指到第一条
  
  函数rsort()
  
  描述:
  
  以倒序方式排列一个数组
  
  Example1.rsort()example
  
  $fruits=array("lemon","orange","banana","apple");
  
  rsort($fruits);
  
  for(reset($fruits);($key,$value)=each($fruits);){
  
  echo"fruits[$key]=".$value." ";
  
  }
  
  Thisexamplewoulddisplay:fruits[0]=orangefruits[1]=lemonfruits[2]=bananafruits[3]=appleThefruitshavebeensortedinreversealphabeticalorder.
  
  函数sizeof()
  
  描述:
  
  取得一个数组的大小和元素的数目
  
  函数sort()
  
  描述:
  
  排序数组
  
  Example1.sort()example
  
  $fruits=array("lemon","orange","banana","apple");
  
  sort($fruits);
  
  for(reset($fruits);
  
  $key=key($fruits);
  
  next($fruits)){
  
  echo"fruits[$key]=".$fruits[$key]." ";
  
  }
  
  Thisexamplewoulddisplay:fruits[0]=applefruits[1]=bananafruits[2]=lemonfruits[3]=orangeThefruitshavebeensortedinalphabeticalorder.
  
  
    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-17471-1.html
网站维护教程更新时间:2012-09-21 05:19:31  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer