日期:2012-10-10 浏览次数:20721 次
<?php $numbers=range(1,9); echo $numbers[1]; ?> |
<?php $numbers=range(a,z); foreach ($numbers as $mychrs) echo $mychrs." "; ?> |
<?php $people=array('name','sex','nation','birth'); foreach ($people as $mychrs) echo $mychrs." "; sort($people); echo "<br />---排序后---<br />"; foreach ($people as $mychrs) echo $mychrs." "; ?> |
<?php echo "---按数字升序排序---<br />"; $num2=array('26','3',); sort($num2,SORT_NUMERIC); foreach ($num2 as $mychrs) echo $mychrs." "; echo "<br />---按字符升序排序---<br />"; $num3=array('26','3'); sort($num3,SORT_STRING); foreach ($num3 as $mychrs) echo $mychrs." "; ?> |
$num1=range(1,9); rsort($num1); |
$peoples=array('xm'=>'name','xb'=>'sex','mz'=>'nation','cs'=>'birth'); |
<?php $peoples=array('xm'=>'name','xb'=>'sex','mz'=>'nation','cs'=>'birth'); foreach ($peoples as $mychrs) echo $mychrs." "; echo "<br />--按元素值升序排列--<br />"; asort($peoples); foreach ($peoples as $mychrs) echo $mychrs." "; echo "<br />--按关键字升序排列--<br />"; ksort($peoples); foreach ($peoples as $mychrs) echo $mychrs." "; ?> |
<?php $fer=array('cnbruce','cnrose','cnjames','cnanne'); shuffle($fer); foreach ($fer as $mychrs) echo $mychrs." "; ?> |