answersLogoWhite

0


Best Answer

foreach is a simple loop mostly used to read an array line by line;

$arr = array("one", "two" , "three");

foreach($arr as $c) {

echo $c;

}

it'll output : onetwothree

also try looking up the while loop

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What purpose is foreach function in php?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the importance of foreach loop in php?

The foreach construct simply gives an easy way to iterate over arrays. Foreach works only on arrays (and objects).


Which loop is used in php?

while, do...while, for, foreach are used


What is the PHP foreach construct used for?

The PHP foreach construct is used to iterate over arrays. This is done in the field of mathematics. It will issue errors when one tries to use it as a variable instead of arrays and objects.


How do you count the vowels in a string using PHP?

build an array of vowels then do a foreach on the array and then explode the string on the array value and the answer is -1 of the result


What purpose does php mail serve?

PHP mail has a variety of functions. The main function is to reroute mail from one server to another. The benefit of doing this is so one doesn't overload the current server.


How does PHP function in applications?

in php used for one typ website


What is the syntax of foreach in c?

There is no 'foreach' in C


How do you use settime out in php?

we cant use set timeout function in php because it is of java script function


How do you return a value in a PHP function?

Below is a simple example of how you could return a value in a PHP function. <?php function returnme($value) { return $value; } echo returnme('hello'); // outputs: hello ?>


What is the way to create a function in PHP?

function function_name() { .................... }


What does the php function eval?

The eval() function evaluates a string as PHP code. http://us.php.net/manual/en/function.eval.php


How do you use a function with a button in PHP?

A simple function call <html> <body> <?php if(isset($_POST['button'])) { setValue(); // Function is called } function setValue() { echo "<br>The button property to call PHP function works"; // Your code here } ?> <input type="submit" name="button" onclick=<?php $_SERVER['PHP_SELF']; ?> /> </body> </head>