Tamil Nadu Board of Secondary EducationHSC Science Class 12

Discuss in detail about Foreach loop. - Computer Applications

Advertisements
Advertisements
Answer in Brief

Discuss in detail about Foreach loop.

Advertisements

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>”;
    }
    ?>
Concept: Looping Structure
  Is there an error in this question or solution?
Chapter 7: Looping Structure - Evaluation - PART – IV [Page 118]

APPEARS IN

Tamil Nadu Board Samacheer Kalvi Class 12th Computer Application Answers Guide
Chapter 7 Looping Structure
Evaluation - PART – IV | Q 2. | Page 118
Share
Notifications



      Forgot password?
Use app×