ലേഖനത്തിൽ, ഒരു അറേയുടെ ആന്തരിക പോയിന്റർ അടുത്ത ഘടകത്തിലേക്ക് എങ്ങനെ നീക്കാമെന്ന് നിങ്ങൾ പഠിക്കും, അടുത്ത () ഫംഗ്ഷൻ ആന്തരിക പോയിന്ററിനെ അടുത്ത ഘടകത്തിലേക്ക് (നിലവിലുണ്ടെങ്കിൽ) നീക്കുകയും അത് ഔട്ട്പുട്ട് ചെയ്യുകയും ചെയ്യുന്നു.
PHP-യിലെ അടുത്ത() ഫംഗ്ഷന്റെ വാക്യഘടന എന്താണ്?
next(array)
പാരാമീറ്റർ | വിവരങ്ങൾ |
---|---|
ശ്രേണി | അടുത്ത ഘടകം ലഭിക്കാനുള്ള അറേ - ആവശ്യമാണ് |
അടുത്ത() ഫംഗ്ഷന്റെ ഉദാഹരണങ്ങൾ
ഉദാഹരണം 1. അറേയുടെ നിലവിലെ മൂല്യവും അടുത്ത മൂല്യവും നേടുക.
<?php
$arr= array("Jawad", "Ahmad", "Sumerina");
echo current($arr);
echo next($arr);
?>
ഉദാഹരണം 2. ഈ ഉദാഹരണത്തിൽ, അടുത്ത രീതി വിഭാഗവുമായി ബന്ധപ്പെട്ട എല്ലാ രീതികളും നിങ്ങൾ കണ്ടെത്തും. ഈ രീതികൾ അറേകളുടെ ആന്തരിക പോയിന്ററുമായി പ്രവർത്തിക്കുന്നു.
<?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));
?>