Gnìomh PHP prev ()

SSL earbsach bho dìreach $3.44
sanasan
An ath ghnìomh PHP
Raon PHP () gnìomh


Anns an artaigil, ionnsaichidh tu mar a ghluaiseas tu puing a-staigh raon chun eileamaid roimhe, Bidh an gnìomh roimhe () a’ gluasad a’ phuing a-staigh chun eileamaid roimhe (ma tha e ann) agus ga chuir a-mach.

Dè an co-chòrdadh a th’ aig a’ ghnìomh roimhe() ann am PHP?

prev(array)
paramadairFiosrachadh
sreathAn raon gus an eileamaid roimhe de - Riatanach fhaighinn
Gnìomh PHP prev ()

Eisimpleirean de ghnìomh roimhe ().

Eisimpleir 1. Faigh an luach làithreach agus an luach roimhe den raon.

<?php
$arr= array("Jawad", "Ahmad", "Sumerina");
echo current($arr);
echo prev($arr);
?>
SSL earbsach bho dìreach $3.44
sanasan

Eisimpleir 2. San eisimpleir seo, gheibh thu a h-uile modh co-cheangailte ris an roinn modh roimhe (). Bidh na modhan sin ag obair le comharradh a-staigh nan arrays.

<?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));
?>



An ath ghnìomh PHP
Raon PHP () gnìomh
dùin

Cùm suas ris an fhiosrachadh as ùire mu PHP!

Cha bhith sinn a’ spamadh!

SSL earbsach bho dìreach $3.44
sanasan
en English
X
Rach gu mhullaich