Chaitanya Lakshmi
  • About Me
  • Job Duties
  • Knowledge Blog
  • Applications
  • Contact Us
    • Linked In
    • Facebook
  • About Me
  • Job Duties
  • Knowledge Blog
  • Applications
  • Contact Us
    • Linked In
    • Facebook

What is the best way to iterate through the $myarray array, assuming you want to modify the value of each element as you do?

2/27/2012

3 Comments

 
<?php
$myarray = array ("My String",
"Another String",
"Hi, Mom!");
?>


  • Using a for loop
  • Using a foreach loop
  • Using a while loop
  • Using a do…while loop
  • There is no way to accomplish this goal
  • I don’t know
Answer:
Using a foreach loop

3 Comments
nithya
4/19/2012 07:53:19 pm

Normally, the foreach statement is the most appropriate construct for iterating through an array. However, because we are being asked to modify each element in the array, this option is not available, since foreach works on a copy of the array and would therefore result in
added overhead. Although a while loop or a do…while loop might work, because the array is sequentially indexed a for statement is best suited for the task, making Answer A correct:

Reply
nithya
4/19/2012 07:54:18 pm

correct me if i am wrong

Reply
Serwis laptopów wrocław link
7/17/2012 01:10:56 pm

New York Travel Tips. [.]below you will discover the link to some sites that we feel you ought to visit[.].

Reply



Leave a Reply.

    Author

    Write something about yourself. No need to be fancy, just an overview.

    Archives

    February 2012

    Categories

    All
    General
    Krds
    Phponweb

    RSS Feed

Powered by Create your own unique website with customizable templates.