1 / 10

ทบทวน Array

ทบทวน Array. คำสั่ง sort และ rsort. คำสั่ง sort ใช้สำหรับเรียงค่าจากน้อยไปมาก คำสั่ง rsort ใช้สำหรับเรียงค่าจากมากไปหาน้อย. คำสั่ง asort และ arsort. ใช้กับ Array แบบคู่ โดยที่ คำสั่ง asort ใช้สำหรับเรียงค่า ( Value) จากน้อยไปมาก

aderes
Download Presentation

ทบทวน Array

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ทบทวนArray

  2. คำสั่ง sort และ rsort • คำสั่ง sort ใช้สำหรับเรียงค่าจากน้อยไปมาก • คำสั่ง rsort ใช้สำหรับเรียงค่าจากมากไปหาน้อย

  3. คำสั่ง asort และ arsort ใช้กับ Array แบบคู่ โดยที่ • คำสั่ง asort ใช้สำหรับเรียงค่า (Value) จากน้อยไปมาก • คำสั่ง arsort ใช้สำหรับเรียงค่า(Value)จากมากไปหาน้อย โดยไม่ได้เรียงลำดับตาม Key

  4. คำสั่ง ksort และ krsort ใช้กับ Array แบบคู่ โดยที่ • คำสั่ง ksort ใช้สำหรับเรียงค่า (Key) จากน้อยไปมาก • คำสั่ง krsort ใช้สำหรับเรียงค่า (Key) จากมากไปน้อย

  5. คำสั่ง reset และ end • คำสั่ง reset ใช้ในการเลื่อนตัวชี้ (Pointer) ที่สมาชิกตัวปัจจุบันกลับไปยังจุดเริ่มต้น • คำสั่ง end ใช้ในการเลื่อนตัวชี้ไปยังสมาชิกตัวสุดท้ายของ Array

  6. การสร้าง Array จากข้อความ • การแปลง Array จากข้อความโดยต้องหาตัวอักษรที่เป็นหลักในการตัดแบ่งออกเป็น Array <? $info=“โปรแกรมคอมพิวเตอร์ และ เทคโนโลยีสารสนเทศ คณะวิทยาศาสตร์ฯ”; $dev=explode(“”,$info); for($i=0;$i<count($dev);$i++){ print(“$i=$dev[$i]<br></n>”); } ?>

  7. การสร้างข้อความจาก Array • การแปลง Array จากข้อความโดยต้องหาตัวอักษรที่เป็นหลักในการตัดแบ่งออกเป็น Array <? $aa=array(“Hello,”, “How”, “are”, “you”); $bb=implode($aa,“”); print(“$bb”); ?>

  8. การสร้างอาร์เรย์ที่มีค่าเป็นลำดับตัวอักษรการสร้างอาร์เรย์ที่มีค่าเป็นลำดับตัวอักษร <? $ar_val=range("a","z"); foreach($ar_val as $eachvalue){ print $eachvalue."<br>\n"; } ?>

  9. การรวมค่าแต่ละ Element เข้าเป็น String <? $abc=array("A"=>"Ant","B"=>"Bird","C"=>"Cat"); print implode(",",$abc); ?>

  10. แบบฝึกหัด ข้อที่ 1 1.รับค่าจำนวนข้อมูลที่ต้องการป้อน 2.สร้าง TEXT BOX ตามจำนวนตัวเลขที่ป้อน 3.ป้อนข้อมูลใน TEXT BOX 4.นำข้อมูลใน Text box เก็บไว้ใน Array แล้วนำข้อมูลใน Array แสดงในอีกหน้า FORM 5.สร้างตัวเลือกให้จัดทำดังนี้ 5.1.การจัดเรียงข้อมูลใน Array จากน้อยไปมาก 5.2.การจัดเรียงข้อมูลใน Array จากมากไปน้อย 5.3.หาค่าสูงสุดใน Array 5.4.หาค่าต่ำสุดใน Array

More Related