2014.01.19数组学习(2)

2014.01.19数组学习(2)
 1 <?php
 2    /*php数组的多种声明
 3      
 4    */
 5      header("content-type:text/html; charset=utf-8");
 6      //1.索引数组
 7      $user[0]=1;
 8      $user[1]="zhangshan";
 9      $user[2]="sex";
10      $user[3]=20;
11      echo"<pre>";
12      print_r($user);
13      //关联数组
14      $class["name"]="lee";
15      $class["age"]=20;
16      $class["sex"]="nan";
17      echo"<pre>";
18      echo$class;
19      //使用array()函数声明
20      $user=array(1,"lee","nan");
21      //这种声明方式是默认为索引数组/
22      echo"<pre>";
23      print_r($user);
24      
25      //要想指定下标则需要使用键值符号=>
26      $user=array("id"=>1,1=>"lee","sex"=>"nan");
27      echo"<pre>";
28      print_r ($user);
29      //多维数组
30      $user=array(
31         
32         array(1,"zhansan","nan"),
33         //为第0个数组
34         array(2,"lisi","nan"),
35         //为第1个数组
36         array(3,"wwu","nan"),
37         //为第2个数组
38         );
39      echo $user[1][1];
40      //或者直接给里面的数组给下标
41       $user=array(
42         
43         "one"=>array(1,"zhansan","nan"),
44         //下标为one的数组
45         "two"=>array(2,"lisi","nan"),
46         //下标为two的数组
47         "three"=>array(3,"wwu","nan"),
48         //three
49         );
50      echo $user["two"][1];
51      
52      ?>
53      
2014.01.19数组学习(2)

2014.01.19数组学习(2)

上一篇:条形码/二维码之开源利器ZXing图文介绍


下一篇:使用Intent调用内置应用程序