php -- 数组
----- 021-array.php -----
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 5 <title>Array</title> 6 </head> 7 <body> 8 <h2>Array</h2> 9 <pre style="font-size:10pt"> 10 <?php 11 $sheeps["灰太狼爱吃"] = "喜羊羊"; 12 $sheeps["邋遢大王爱吃"] = "美羊羊"; 13 $sheeps["熊大爱吃"] = "懒羊羊"; 14 $sheeps["葫芦娃爱吃"] = "喜羊羊"; 15 $sheeps["熊二爱吃"] = "美羊羊"; 16 $sheeps["红太狼爱吃"] = "懒羊羊"; 17 echo "\$是否为数组?", is_array($sheeps), "\n"; 18 echo "是否包含喜羊羊?", in_array("喜羊羊", $sheeps), "\n"; 19 echo "谁爱吃喜羊羊:", var_export(array_keys($sheeps, "喜羊羊")), "\n"; 20 echo "有多少羊?", var_export(array_values($sheeps)), "\n"; 21 echo "有没有邋遢大王爱吃的羊?", array_key_exists("邋遢大王爱吃", $sheeps), "\n"; 22 echo "懒羊羊谁爱吃?", array_search("懒羊羊", $sheeps), "\n"; 23 24 array_push($sheeps, "沸羊羊"); 25 array_unshift($sheeps, "慢羊羊"); 26 echo "加上俩:", var_export($sheeps), "\n"; 27 echo "填充到10个:", var_export(array_pad($sheeps, -10, "无名之羊")), "\n"; 28 echo "去重后:", var_export(array_unique($sheeps)), "\n"; 29 $temp = $sheeps; 30 sort($temp); 31 echo "排序后:", var_export($temp), "\n"; 32 echo "哪只最好吃?", var_export(array_count_values($sheeps)), "\n"; 33 //error_reporting(0);//不报告错误 34 echo "当前时间", date("Y年m月d日H时i分s秒", time()+28800),"\n"; 35 ?> 36 </pre> 37 </body> 38 </html>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。