what is the diffrence between for and foreach?

Answer Posted / krunal gohel

for loop is to do something over and over again until the
task has been completed.

foreach works only on arrays. even it will run the loop
until end of the array.

Is This Answer Correct ?    15 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What language is php written in?

581


What is rtrim php?

543


What is default session time and path in PHP. How to change it?

541


What are php string functions?

524


Explain me what are the main error types in php and how do they differ?

542






How arrays are passed through arguments?

608


Tell me how to get the value of current session id?

503


What is filter_var?

533


What does $_env mean?

566


Binary tree question - Node has numeric data (int) The function takes depth as argument and sum all the value of the node of the depth. For instance, (0) depth 0 / \ 10 20 depth 1 / \ / \ 40 50 60 70 depth 2 so if you pass get_sum(2), you would return 220 which is 40+50+60+70 (sum of depth2) write the function.

1504


What is use of htmlspecialchars php?

510


Tell me how do you define a constant?

521


Where is session id stored?

515


Why print_r is used in php?

533


Which function would you use to read a line of data from a file in php?

559