ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

4-2 ¦hºû°}¦C(4-2-1 ¤Gºû°}¦Cªº«Å§i)

4-2 ¦hºû°}¦C(4-2-1 ¤Gºû°}¦Cªº«Å§i)

4-2   ¦hºû°}¦C¦hºû°}¦C¡]Multi-dimensional¡^¡A°}¦C¤¤ÁÙ¦³°}¦C´NºÙ¤§¦hºû°}¦C¡A§Ú­Ì¤§«e©Ò»¡©úªº¬O¤@ºû°}¦C¡A¦]¬°§Ú­Ì¥u«ü©w¤F¤@­Ó°}¦C­Ó¼Æ¯Á¤Þ¡A¦pªG§Ú­Ì«ü©w¤F¨â­Ó°}¦C­Ó¼Æ¯Á¤Þ¡A¨º³o­Ó°}¦C´N¦¨¬°¤Gºû°}¦C¡A­Y¦pªG§Ú­Ì«ü©w¤F¤T­Ó°}¦C­Ó¼Æ¯Á¤Þ¡A¨º³o­Ó°}¦C´N¦¨¬°¤Tºû°}¦C¡A¥H¦¹Ãþ±À¡C
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

4-2-1   ¤Gºû°}¦Cªº«Å§i
¤@ºû°}¦C¬O¥u¦³¤@¦æªº¸ê®Æ±Æ¦C¡A¦Ó¤Gºû°}¦Cªº¸ê®Æ±Æ¦C´N¦p¦Pªí®æ¤@¯ë¡A¤À¬°¡u¦æ¡v»P¡u¦C¡v¡G

¹Ï4-7  ¤Gºû°}¦Cªº¡u¦æ¡v»P¡u¦C¡v¡C
©Ò¥H¡A§Ú­Ì­n¨Ï¥Î¤Gºû°}¦C®É¡A´N­n¦p¤U¦C¤è¦¡¨Óªì©l¡G
¼Ð·Ç°}¦Cªì©l®æ¦¡
  1. $°}¦C¦WºÙ[X][Y]=ªì©l­È;
½Æ»s¥N½X
¤W¦¡¤¤¡G¡uX¡v¬°¡u¦C¡vªº¤j¤p¡F¡uY¡v¬°¡u¦æ¡vªº¤j¤p¡C
¨Ò¦p¡G ªì©l¤@­Ó3x2ªº¤Gºû°}¦C
  1. $Myarray[0][0]="¤p»x";
  2. $Myarray[0][1]="egge";
  3. $Myarray[1][0]="chiey";
  4. $Myarray[1][1]="connie";
  5. $Myarray[2][0]="¤p³½";
  6. $Myarray[2][1]="¤p©M";
½Æ»s¥N½X
ª`·N³á¡I«Å§i¤@­Ó3x2ªº¤Gºû°}¦C¡A¨ä¦Cªº³Ì¤jµù¼ÐÀ³¸Ó¬°2¦æªº³Ì¤jµù¼ÐÀ³¸Ó¬O1¤~¹ï³á¡I¨ä¤¤¦C¤¸¯À¬O0~2¦@¤T­Ó¡A¦æ¤¸¯À«h¬O0~1¦@¨â­Ó¡G

1.png
¹Ï4-8   3x2ªº¤Gºû°}¦C¡C
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

°²³]§Ú­Ì¦³¤@­Ó¾Ç¥Í¦¨¿nªí®æ¦p¤U¹Ï¡A½Ð¥H¤Gºû°}¦C¤è¦¡Àx¦sªí®æ¤º¸ê®Æ¡G

¹Ï4-9   ¾Ç¥Í¦¨ÁZªí¡C

­n±Nªí®æ¸ê®ÆÂà´«¦¨°}¦C§Î¦¡¡A§Ú­Ì¥i¥H³o¼Ë°µ¡G
  1. $Student[0][0]=¡¨©m¦W¡¨; //¡¥±N²Ä¤@¦C²Ä¤@¦æªº¸ê®Æ«ü©w¬°¡¨©m¦W¡¨
  2. $Student[0][1]=¡¨°ê¤å¡¨; //±N²Ä¤@¦C²Ä¤G¦æªº¸ê®Æ«ü©w¬°¡¨°ê¤å¡¨
  3. ¥H¤U²¤¡K
½Æ»s¥N½X
´N¬O¥H³v­Ó¤¸¯À¸ê®Æ¶ñ¤Jªº¤è¦¡¡A¯÷±N¤¸¯Àµù¼Ð¹ï·Ó¦p¤U¹Ï;

¹Ï4-10   ¦æ¦Cµù¼Ð¹ï·Ó¡C
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

array()¨ç¼Æ¥ç¥iÀ³¥Î©ó¤Gºû°}¦Cªºªì©l¡A°µªk¬O¡G±N¡u¦C¡vµø¬°¤@ºû°}¦C¡A¦Ó¦¹¤@¡u¦C¡v°}¦Cªº¤¸¯À«h¬°¡u¦æ¡v°}¦C¡A¥H¹Ï4-9¾Ç¥Í¦¨ÁZªí¨Ó»¡¡G¡]ex04_11.php¡^
  1. $Student=array(
  2. "0"=>array(0=>"©m¦W",1=>"°ê¤å",2=>"­^¤å",3=>"¼Æ¾Ç"),
  3. "1"=>array(0=>"¤p»x",1=>100,2=>90,3=>80),
  4. "2"=>array(0=>"±oµØ",1=>60,2=>100,3=>70),
  5. "3"=>array(0=>"«F«Ê",1=>90,2=>80,3=>90),
  6. "4"=>array(0=>"¾Ç¦³",1=>65,2=>90,3=>80));
½Æ»s¥N½X
·íµM¡A¹ï©ó«D³sÄòµù¼Ðªº¤Gºû°}¦C©Î¬O¦r¦êµù¼Ð°}¦C¡A¨Ï¥Îarray()¨ç¼Æ¤]¬O¦æªº³qªº¡A¨Ò¦p¡G¡]ex04_12.php¡^
  1. <?
  2. $Student=array(
  3. "¤p»x"=>array("a"=>100,2=>90,"b"=>80),
  4. "±oµØ"=>array(1=>60,"c"=>100,3=>70),
  5. "«F«Ê"=>array("d"=>90,2=>80,"e"=>90));
  6. ?>
½Æ»s¥N½X
¤W¨Òµ¥¦P¡G
  1. $Student["¤p»x"]["a"]=100;
  2. $Student["¤p»x"][2]=90;
  3. $Student["¤p»x"]["b"]=80;

  4. $Student["±oµØ"][1]=60;
  5. $Student["±oµØ"]["c"]=100;
  6. $Student["±oµØ"][3]=70;

  7. $Student["«F«Ê"]["d"]=90;
  8. $Student["«F«Ê"][2]=80;
  9. $Student["«F«Ê"]["e"]=90;
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP


¦æ(ª½ªº)
¦C(¾îªº)

TOP

        ÀR«ä¦Û¦b : ¤£­n¤p¬Ý¦Û¤v¡A¦]¬°¤H¦³µL­­ªº¥i¯à¡C
ªð¦^¦Cªí ¤W¤@¥DÃD