answersLogoWhite

0

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.

User Avatar

Wiki User

11y ago

What else can I help you with?

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 purpose is foreach function in php?

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


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 is the syntax of foreach in c?

There is no 'foreach' in C


How do you create a loop using PHP?

There are a number of different ways to loop using PHP. They're as follows:ForForeachWhileDo-whileBelow are some examples of how each of these types of loop work.ForForeachWhileDo-while


Is it mandatory to use array in foreach loop C-sharp can foreach be used without array?

Foreach is for an IEnumerable, not just an array (unless you are using C# 1.1 or earlier). A collection (List, Dictionary, etc) can also generate a sequence from foreach-statement. In fact, if you have a class that is NOT an array, but it implements all the required methods of IEnumerable, it may be applied as:public class Storage: IEnumerable {...}Storage myStorage = new Storage();...Foreach (Thing stuff in myStorage){...}


How do you check which extensions are dynamically loaded in PHP?

AnswerTo get the list of currently loaded extensions within a PHP program. Use get_loaded_extensions() function.To check what extensions are loaded by PHP on a given server, type this on the command line:php -mHere is a php script that will list the loaded extensions in a table. Save this file as phpext.php and place it on your website. Go to this file in your web browsers and see a list of loaded extensions:


What is the PHP IF construct used for?

The IF construct allows a programmer to create conditional arguments based on the returned results of a certain tasks. In layman's terms it allows a program to execute a certain set of instructions if a certain criteria is met and a second set of instructions if that criteria is not met.


Which language is used more for websites PHP or ASP.net?

Php


How do you write a program to print prime numbers from 1 to 100 in PHP?

<pre> <?php $limit = 100; $primeList = array(); for($i = 2; $i < round(sqrt($limit)); $i++) { foreach($primeList as $num) { if($i%$num 0)) continue 2; } $prime[] = $i; } print_r($prime); ?> </pre> Based on Sieve of Erathosthenes. See the related link for further information.


What is the use of a question mark in php?

It is used to tell the sever to use the PHP parser. To begin php you must use <?php, and to end it, it is ?>.