This forum is now read-only. Please use our new forums at discuss.codecademy.com.

For Loops in PHP Forum

View Course » View Exercise

437 points
589107aae12813479e000234_14361109
Submitted by
Fcking Clown
over 2 years ago

What is the foreach loop for?

Hey,
why should i use a foreach loop?
couldnt i just let php print out the array? without using that loop?


-1 votes

permalink

<?php>
$a = array("i m enjoying php");
foreach ($a & $word);
$ word;

for loop//foreach replace $sentance to $a . ok bye.... write if u donot understand.

95 points
5434c1e1282ae3f7e7000b12_825134351
Submitted by
radhaballav khamari
over 2 years ago


-1 votes

permalink

<?php
$a = array("I'm ", "learning ", "PHP!");

    foreach ($a as $word) {

      echo $word;
    }
  ?>
</p>

95 points
5434c1e1282ae3f7e7000b12_825134351
Submitted by
radhaballav khamari
over 2 years ago