Good and Honest Host of the month, September 2008,
WSServers.com
Thank you for visiting this site. If you are looking for web hosting
services, you have come to the right place. Please search my database of
over 2400
hosting companies.
If you need any help, please email me at terence @ hostpulse.com . I
will personally try to reply your email within a day and give you some basic
guidelines, negotiate with a few hosts to offer you good pricing or
answer any hosting related problems that you may have.
PHP 4 introduced a foreach construct, much
like Perl and some other languages. This simply gives an easy way to
iterate over arrays. foreach works only on arrays, and
will issue an error when you try to use it on a variable with a different
data type or an uninitialized variable. There are two syntaxes; the
second is a minor but useful extension of the first:
foreach (array_expression as $value)
statement
foreach (array_expression as $key => $value)
statement
The first form loops over the array given by
array_expression. On each loop, the value of
the current element is assigned to $value and
the internal array pointer is advanced by one (so on the next
loop, you'll be looking at the next element).
The second form does the same thing, except that the current
element's key will be assigned to the variable
$key on each loop.
Note:
When foreach first starts executing, the
internal array pointer is automatically reset to the first element
of the array. This means that you do not need to call
reset() before a foreach
loop.
Note:
Also note that foreach operates on a copy of
the specified array and not the array itself. Therefore, the
array pointer is not modified as with the
each() construct, and changes to the array
element returned are not reflected in the original array.
However, the internal pointer of the original array
is advanced with the processing of the
array. Assuming the foreach loop runs to completion, the
array's internal pointer will be at the end of the array.
As of PHP 5, you can easily modify array's elements by preceding
$value with &. This will assign
reference instead of copying
the value.
<?php $arr = array(1, 2, 3, 4); foreach ($arr as &$value) { $value = $value * 2; } // $arr is now array(2, 4, 6, 8) ?>
This is possible only if iterated array can be referenced (i.e. is
variable).
Note: foreach does not support the ability to
suppress error messages using '@'.
You may have noticed that the following are functionally
identical:
Web Hosting Showcase
View the web hosting
showcase to find more relevant web hosting choice that will guide you in
selecting a good web hosting company.
This site provide
free reviews of web hosting services from 100 selected companies. There
are over 3000 over website hosting companies on the internet. Please
research these domain hosting services carefully before you sign up with
any. Read articles on web page hosting, web site hosting, domain names,
website speed test, cheap web hosting services, PHP scripts, mysql
database, asp hosting and virtual private server to gain a better
knowledge on domain hosting and cheap web hosting.