Php - foreach

Card Puncher Data Processing

About

foreach is a loop structure over an array

For each

See also: PHP - For loop

Example

$colors = array('red', 'blue', 'green', 'yellow');

foreach ($colors as $color) {
    echo "Do you like $color?\n";
}


// Changing element in the loop
foreach ($colors as $key => $color) {
    $colors[$key] = strtoupper($color);
}





Discover More
Card Puncher Data Processing
Php - (Loop|Iteration)

in php
Card Puncher Data Processing
Php - Array (Map)

In Php, an array is an(ordered|sorted) map (keys/value) Array can contain others arrays. The key can either be an integer or a string (in the same array - PHP does not distinguish between indexed...



Share this page:
Follow us:
Task Runner