ഈ ലേഖനത്തിൽ, പിഎച്ച്പിയിലെ ഒരു അറേയുടെ അവസാന ഘടകം എങ്ങനെ നേടാമെന്ന് നിങ്ങൾ പഠിക്കും. എൻഡ് ഫംഗ്ഷൻ ഒരു അറേയുടെ ആന്തരിക പോയിന്ററിനെ അവസാന ഘടകത്തിലേക്ക് നീക്കുകയും അതിന്റെ മൂല്യം തിരികെ നൽകുകയും ചെയ്യുന്നു.
PHP-യിലെ എൻഡ് ഫംഗ്ഷന്റെ വാക്യഘടന എന്താണ്?
end(array)
പാരാമീറ്റർ | വിവരങ്ങൾ |
---|---|
ശ്രേണി | ഇതിന്റെ അവസാന ഘടകം ലഭിക്കാനുള്ള അറേ - ആവശ്യമാണ് |
അവസാന പ്രവർത്തനത്തിന്റെ ഉദാഹരണം
ഉദാഹരണം 1. അറേയുടെ അവസാന ഘടകം നേടുക.
<?php
$members= array("Jawad", "Ahmad", "Sumerina");
echo end($members);
?>
ഉദാഹരണം 1. ഈ ഉദാഹരണത്തിൽ, അവസാന രീതി വിഭാഗവുമായി ബന്ധപ്പെട്ട എല്ലാ രീതികളും നിങ്ങൾ കണ്ടെത്തും. ഈ രീതികൾ അറേകളുടെ ആന്തരിക പോയിന്ററുമായി പ്രവർത്തിക്കുന്നു.
<?php
$members= array("Jawad", "Ahmad", "Sumerina", "ACS");
// Current element: Jawad
echo current($people) . "<br>";
// Next element of Jawad: Ahmad
echo next($people) . "<br>";
// Now the current element: Ahmad
echo current($people) . "<br>";
// Previous element of Ahmad: Jawad
echo prev($people) . "<br>";
// Last element: ACS
echo end($people) . "<br>";
// Previous element of ACS: Sumerina
echo prev($people) . "<br>";
// Current element: Sumerina
echo current($people) . "<br>";
// Move the internal pointer to the first element of the array:Jawad
echo reset($people) . "<br>";
// Next element of Jawad: Ahmad
echo next($people) . "<br>";
// Get key and value of Ahmad (current element) then moves the internal pointer forward
print_r (each($members));
?>