0

would you please help me out with the following code?

<?php $i = 1; $names = array("Dar", "Sara", "kozet"); foreach ($names as $name) { do { echo "the number $i name is: " . $name . "<br />"; } while ($i <=3); $i++; ?> I want to print names by number under the specific condition. Thank you

7th Aug 2017, 1:37 PM
Dariush Shiri
Dariush Shiri - avatar
3 Answers
+ 4
https://code.sololearn.com/wwEPT230dtwr/#php <?php $i = 1; $names = array("Dar", "Sara", "kozet"); foreach ($names as $name) { echo "the number $i name is: " . $name . "<br>"; $i++; } ?> ####OUTPUT#### the number 1 name is: Dar the number 2 name is: Sara the number 3 name is: kozet
7th Aug 2017, 1:44 PM
AgentSmith
+ 5
<?php $names = array("Dar", "Sara", "kozet"); foreach ($names as $i => $name) { echo "the number $i name is: " . $name . "<br />"; } ?>
7th Aug 2017, 1:47 PM
visph
visph - avatar
+ 2
thank YOU guys :)
7th Aug 2017, 1:56 PM
Dariush Shiri
Dariush Shiri - avatar