php -- 數組

來源:互聯網
上載者:User

標籤:style   class   blog   c   code   java   

----- 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 <?php11     $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>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.