PHP pos() ພິທີ

PHP

ຄວາມພາບ

ການອອກສຽງຄະແນນວ່າຫົວເມືອງທີ່ມີໃນສາຍອາກາດລະບົບ.

<?php
$people = array("Bill", "Steve", "Mark", "David");
echo pos($people) . "<br>";
?>

Run Examples

ການກໍານົດແລະການນໍາໃຊ້

pos() ພິທີກັບຄືນຄະແນນວ່າຫົວເມືອງທີ່ມີໃນສາຍອາກາດລະບົບ.

ການປະກອບກຳລັງຂອງບູລິບາງພິທີນີ້ current() ນາມວິທະຍຸ

ແຕ່ລະອາກາດລະບົບມີສິ່ງເຄືອງພາຍໃນອາກາດລະບົບທີ່ຈະອອກສຽງຫົວເມືອງ"ປັດຈຸບັນ"ທຳອິດເວລາມີສາຍອາກາດລະບົບ.

ຄຳແນະນຳການຕິດຕາມວ່າບໍ່ໄດ້ຍ້າຍສິ່ງເຄືອງພາຍໃນອາກາດລະບົບ.

ວິທະຍຸການເປັນຫນຶ່ງ

  • current() - ກັບຄືນຄະແນນວ່າຫົວເມືອງທີ່ມີໃນສາຍອາກາດລະບົບ.
  • end() - ປ່ຽນສິ່ງເຄືອງພາຍໃນອາກາດລະບົບໄປຫາຫົວເມືອງທີ່ມີໃນສາຍອາກາດລະບົບທີ່ມີໃນສາຍອາກາດລະບົບສຸດທ້າຍແລະອອກສຽງອອກ.
  • next() - ປ່ຽນສິ່ງເຄືອງພາຍໃນອາກາດລະບົບໄປຫາຫົວເມືອງທີ່ມີໃນສາຍອາກາດລະບົບທຳອິດແລະອອກສຽງອອກ.
  • prev() - ປ່ຽນສິ່ງເຄືອງພາຍໃນອາກາດລະບົບໄປຫາຫົວເມືອງທີ່ມີໃນສາຍອາກາດລະບົບທີ່ມີໃນສາຍອາກາດລະບົບກ່ອນແລະອອກສຽງອອກ.
  • reset() - ປ່ຽນສິ່ງເຄືອງພາຍໃນອາກາດລະບົບໄປຫາຫົວເມືອງທີ່ມີໃນສາຍອາກາດລະບົບທຳອິດແລະອອກສຽງອອກ.
  • each() - ກັບຄືນຄະແນນຫົວເມືອງແລະຄະແນນທີ່ມີໃນສາຍອາກາດລະບົບແລະປ່ຽນສິ່ງເຄືອງພາຍໃນອາກາດລະບົບຕໍ່ໄປ.

ວິທະຍຸ

pos(array)
ພິທີການ ການອະທິບາຍ
array ຄວາມຈໍາເປັນ

ຂໍ້ສານດ້ານເຕັກນິກ

ຄະແນນກັບຄືນ ກັບຄືນຄະແນນວ່າຫົວເມືອງທີ່ມີໃນສາຍອາກາດລະບົບມັນຈະບັງຄັບຄວາມບໍ່ມີຄວາມຜິດພາດພາຍໃນອາກາດລະບົບ.
PHP Version: 4+

More Examples

Example 1

Demonstrate all related methods:

<?php
$people = array("Bill", "Steve", "Mark", "David");
echo current($people) . "<br>"; // The current element is Bill
echo next($people) . "<br>"; // Bill's next element is Steve
echo current($people) . "<br>"; // The current element is Steve
echo prev($people) . "<br>"; // Bill's previous element is Steve
echo end($people) . "<br>"; // The last element is David
echo prev($people) . "<br>"; // Mark's previous element is David
echo current($people) . "<br>"; // The current element is Mark
echo reset($people) . "<br>"; // Moves the internal pointer to the first element of the array, which is Bill
echo next($people) . "<br>"; // Bill's next element is Steve
print_r (each($people)); // Returns the key name and value of the current element (currently Steve) and moves the internal pointer forward
?>

Run Examples

PHP