हिंदी
तमिलनाडु बोर्ड ऑफ सेकेंडरी एज्युकेशनएचएससी विज्ञान कक्षा १२

Explain working of loops in array.

Advertisements
Advertisements

प्रश्न

Explain working of loops in array.

संक्षेप में उत्तर
Advertisements

उत्तर

Using Foreach loop:

  • The foreach statement is used to loop through arrays.
  • For each pass, the value of the current array element is assigned to $value and the array pointer is moved by one and in the next pass, the next element will be processed.

Example:

<?php
$Student_name = arrayO’Magilan”, “Iniyan”, “Nilani” “Sibi” “Shini”); foreach ($Student_name as $value) { echo “$value <br>”;
}
?>

Using For Loop:

To loop through and print all the values of an indexed array.

Example:

<?php$cars = arrayC’Volvo”, “BMW”, “Toyota”);
$arrlength = count(cars);
for($x = 0; $x < $arrlength; $x++){
echo $cars[$x];
echo “<br>”;
}
?>
shaalaa.com
Looping Structure
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 7: Looping Structure - Evaluation - PART – IV [पृष्ठ ११८]

APPEARS IN

सामाचीर कलवी Computer Applications [English] Class 12 TN Board
अध्याय 7 Looping Structure
Evaluation - PART – IV | Q 5. | पृष्ठ ११८
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×