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

4-1-4 ¦r¦êµù¼Ð°}¦C

4-1-4 ¦r¦êµù¼Ð°}¦C

4-1-4   ¦r¦êµù¼Ð°}¦C
¦r¦êµù¼Ð°}¦C¨ä¹ê¤]¬O«D³sÄòµù¼Ð°}¦C¡A³q±`°}¦Cªºµù¼Ð¯Á¤Þ³£·|¥H¾ã¼Æ¨Ó§@¬°ÃѧO½s¸¹¡A¦ýPHP¤¤¤¹³\§Ú­Ì¥H¦r¦ê¨Ó§@¬°µù¼ÐÃѧO¯Á¤Þ¡G¡]ex04_08.php¡^
  1. <?
  2. $Myarray["charles"] = "¤p»x";
  3. $Myarray["egge"] = "¤p³½";
  4. $Myarray["chiey"] = "¤pÃQ";
  5. $Myarray["connie"] = "µL§Àºµ";

  6. foreach ($Myarray as $value)
  7. {
  8. echo "$value <br>";
  9. }
  10. ?>
½Æ»s¥N½X
¦pªG¨Ï¥Î¦r¦êµù¼Ð°}¦C¡A¨ºarray()¨ç¼ÆÁÙ¥i¥H¨Ï¥Î¶Ü¡H·íµM¥i¥H¡A¦ý¬O¥²¶·°t¦X¡y=>¡]«ü¼Ð¡B«ü¦V¡^¡z¹Bºâ¤l¡A§â¦r¦êµù¼Ð¸ò¤¸¯À­È¤À§OÂ\©ñ¦b¡y=>¡]«ü¼Ð¡B«ü¦V¡^¡z¹Bºâ¤l¥ª¥k¨â°¼¡G¡]ex04_09.php¡^
  1. <?
  2. $Myarray=array("charles" => "¤p»x",
  3.                "egge" => "¤p³½",
  4.                "chiey" => "¤pÃQ",
  5.                "connie" => "µL§Àºµ");

  6. foreach ($Myarray as $value)
  7. {
  8. echo "$value <br>";
  9. }
  10. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

foreach°j°éªº¶i¶¥¨Ï¥Î
³q±`§Ú­Ì¬O¤£»Ý­n¨Ï¥Î¨ì¤¸¯Àªºµù¼Ð­È¡A¦ý¬O±z¬JµM¨Ï¥Î¦r¦êµù¼Ð°}¦C¡A·Q¥²¨Ï¥Î¨ìµù¼Ð­Èªº¾÷·|´N¤ñ¸û¤j¤F¡A¼Ð·Çªºforeach°j°é±Ô­z´N¤£°÷¥Î¤F¡A³o®É­Ô¥i¥H¨Ï¥Î¶i¶¥ªºforeach°j°é±Ô­z¡G
foreach°j°é±Ô­z®æ¦¡
  1. foreach(°}¦C as $key => $value)
  2. {
  3.      ±Ô­z°Ï¶ô;
  4. }
½Æ»s¥N½X
¤W¦¡¤¤ªº¡u$value¡v¥u¬O¤@­Ó¼È¦sÅܼơA¥Î¨ÓÁ{®É¸Ë¸ü°}¦C¤¤ªº¤¸¯À¸ê®Æ­È¡A¦Ó¡u$key¡v¤]¬O¤@­Ó¼È¦sÅܼơA¥Î¨ÓÁ{®É¸Ë¸ü°}¦C¤¤ªº¤¸¯Àµù¼Ð¡A¨Ò¦p¡G¡]ex04_10.php¡^

¹Ï4-6   ex04_10.php¡C
  1. <?
  2. $Myarray=array("charles" => "¤p»x",
  3.                "egge" => "¤p³½",
  4.                "chiey" => "¤pÃQ",
  5.                "connie" => "µL§Àºµ");

  6. foreach ($Myarray as $key => $value)
  7. {
  8. echo "¤¸¯Àµù¼Ð: $key ; ¤¸¯À­È: $value <br>";
  9. }
  10. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

        ÀR«ä¦Û¦b : ÁÀ¨¥¹³¤@¦·²±¶}ªºÂAªá¡A¥~ªí¬üÄR¡A¥Í©Rµu¼È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD