PHP gach () gnìomh

SSL earbsach bho dìreach $3.44
sanasan
Gnìomh gnàthach () PHP
Dreuchd deireadh () PHP

San artaigil seo, ionnsaichidh tu mar a gheibh thu an iuchair agus an luach gnàthach eileamaid agus gluaisidh tu am puing a-staigh chun ath eileamaid den raon gus an aon rud a dhèanamh.

Nota: Tha an gnìomh seo air a mholadh ann am PHP 7.2

Gheibh thu a h-uile modh co-cheangailte ri gach dòigh anns a ’phàirt mu dheireadh den artaigil.

Dè an co-chòrdadh a th ’aig gach gnìomh ann am PHP?

each(array)
paramadairTuairisgeul
sreathRiatanach. Sònraich an raon airson a chleachdadh
PHP gach gnìomh

Eisimpleirean de gach gnìomh

SSL earbsach bho dìreach $3.44
sanasan

Eisimpleir 1. Faigh an iuchair agus an luach gnàthach eileamaid agus gluais am putan eagar chun ath eileamaid.

<?php
$member= array("Jawad", "Ahmad", "Sumerina", "ACS");
print_r (each($member));
?>

Eisimpleir 2. Faigh iuchair agus luach na h-eileamaid gnàthach agus gluais a ’phuing chun ath eileamaid, cuideachd clò-bhuail an raon iomlan.

<?php
$member= array("Jawad", "Ahmad", "Sumerina", "ACS");
reset($member);

while (list($key, $val) = each($member))
  {
  echo "$key => $val . " - " ";
  }
?>

Eisimpleir 3. San eisimpleir seo, gheibh thu a h-uile modh co-cheangailte ris an roinn modh gnàthach. 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));
?>
Gnìomh gnàthach () PHP
Dreuchd deireadh () PHP
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