Willkommen auf meinem Apache-Webserver!

Dieser Server verwendet MariaDB 10.11.8-MariaDB-0ubuntu0.24.04.1

Wissensportal

PHP

<?php
$tiere = ["Wal", "Gans", "Affe", "Nashorn", "Zebra", "Esel"];
$counter = 0;

// foreach ($tiere as $tier) {
//    $counter += 1;
//    echo "$counter " . "ist " . $tier . "\n";
// }

foreach ($tiere as $tier) {
    $counter += 1;
    echo "Nr. $counter " . "ist " . $tier . "\n";
}
?>

PHP (Alternative Syntax)

<?php
$tiere = ["Wal", "Gans", "Affe", "Nashorn", "Zebra", "Esel"];
$counter = 0;
?>


<?php foreach ($tiere as $tier): ?>
  <?php 
    // $counter += 1;
    // echo "$counter " . "ist " . $tier . "\n";
    ?>
<?php endforeach; ?>

<?php foreach ($tiere as $tier): ?>
    <?php
        $counter += 1;
        echo "Nr. $counter " . "ist " . $tier . "\n";
    ?>
<?php endforeach; ?>

Python

tiere = ["Wal", "Gans", "Affe", "Nashorn", "Zebra", "Esel"]
           #0      #1     #2       #3         #4      #5

counter = 0

#for tier in tiere:
#    counter += 1
#    print(counter)

for tier in tiere:
    counter += 1
    print(f"Nr. {counter} ist {tier}")