end()
PHP end() funksiyasi
❮ PHP massivlar ma’lumotnomasi
Misol
Massivdagi joriy va oxirgi elementning qiymatini chiqaring:
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>";
echo end($people);
?>
O‘zingiz sinab ko‘ring »
Ta’rif va qo‘llanilishi
end() funksiyasi ichki ko‘rsatkichni massivdagi oxirgi elementga siljitadi va uni chiqaradi.
Tegishli metodlar:
- current() - massivdagi joriy elementning qiymatini qaytaradi
- next() - ichki ko‘rsatkichni massivdagi keyingi elementga siljitadi va uni chiqaradi
- prev() - ichki ko‘rsatkichni massivdagi oldingi elementga siljitadi va uni chiqaradi
- reset() - ichki ko‘rsatkichni massivning birinchi elementiga siljitadi
- each() - joriy elementning kaliti va qiymatini qaytaradi hamda ichki ko‘rsatkichni oldinga siljitadi
Sintaksis
end(array)
Parametr qiymatlari
| Parametr | Tavsif |
|---|---|
| array | Majburiy. Foydalaniladigan massivni belgilaydi |
Texnik tafsilotlar
| Qaytariladigan qiymat: | Muvaffaqiyatli bo‘lsa, massivdagi oxirgi elementning qiymatini, massiv bo‘sh bo‘lsa esa FALSE qaytaradi |
|---|---|
| PHP versiyasi: | 4+ |
Ko‘proq misollar
Misol
Barcha tegishli metodlarning namoyishi:
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>"; // The current element is Peter
echo next($people) . "<br>"; // The next element of Peter is Joe
echo current($people) . "<br>"; // Now the current element is Joe
echo prev($people) . "<br>"; // The previous element of Joe is Peter
echo end($people) . "<br>"; // The last element is Cleveland
echo prev($people) . "<br>"; // The previous element of Cleveland is Glenn
echo current($people) . "<br>"; // Now the current element is Glenn
echo reset($people) . "<br>"; // Moves the internal pointer to the first element of the array, which is Peter
echo next($people) . "<br>"; // The next element of Peter is Joe
print_r (each($people)); // Returns the key and value of the current element (now Joe), and moves the internal pointer forward
?>
O‘zingiz sinab ko‘ring »
❮ PHP massivlar ma’lumotnomasi
W3Schools Pathfinder
Yutuqlaringizni kuzating – bu bepul!
