Study PHP-01

來源:互聯網
上載者:User

標籤:

第一天開始學習php 想通過部落格記錄一下筆記 以便複習!

因為以前看過某些資料 直接從數組開始學習

 

1.定義數組 array()

可以用 array() 語言結構來建立一個數組。它接受任意數量用逗號分隔的    鍵(key) => 值(value) 對。  

array(  key =>  value     , ...     )// 鍵(key)可是是一個整數  integer  或字串  string // 值(value)可以是任意類型的值

樣本 $arr=array(1=>"one",2=>"two")
MY:其中1和2就是key,one和two就是value,也就是說$arr[1]="one";key的值可以是字元也可以是數字。$arr[‘title‘]不能寫成$arr[title]
函數count($函數名) 可以有多少key!

使用樣本:

<?php
// This:
$a = array( ‘color‘ => ‘red‘ ,
            ‘taste‘ => ‘sweet‘ ,
            ‘shape‘ => ‘round‘ ,
            ‘name‘  => ‘apple‘ ,
            4        // key will be 0
          );

$b = array( ‘a‘ , ‘b‘ , ‘c‘ );

// . . .is completely equivalent with this:
$a = array();
$a [ ‘color‘ ] = ‘red‘ ;
$a [ ‘taste‘ ] = ‘sweet‘ ;
$a [ ‘shape‘ ] = ‘round‘ ;
$a [ ‘name‘ ]  = ‘apple‘ ;
$a []        = 4 ;        // key will be 0

$b = array();
$b [] = ‘a‘ ;
$b [] = ‘b‘ ;
$b [] = ‘c‘ ;
 

Study PHP-01

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.