English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

Discuss in detail about Foreach loop. - Computer Applications

Advertisements
Advertisements

Question

Discuss in detail about Foreach loop.

Answer in Brief

Solution

  • 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 next element will be processed.

    Foreach loop Structure and Flow
  • Syntax:
    foreach ($array as $value) {
    code to be executed;
    }
  • Example:

    <?php
    $Student_name = a rrayÇ’MagiIan’ “Iniyan’
    “NiIani’ “Sibi’ “Shini”);
    foreach ($Student_name as $value) {
    echo “$value <br>”;
    }
    ?>
shaalaa.com
Looping Structure
  Is there an error in this question or solution?
Chapter 7: Looping Structure - Evaluation - PART – IV [Page 118]

APPEARS IN

Samacheer Kalvi Computer Applications [English] Class 12 TN Board
Chapter 7 Looping Structure
Evaluation - PART – IV | Q 2. | Page 118
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×