|
Posted by Rik on 03/01/07 03:37
On Tue, 27 Feb 2007 23:22:55 +0100, OmegaJunior =
<omegajunior@spamremove.home.nl> wrote:
> On Tue, 27 Feb 2007 14:08:10 +0100, Mike Roetgers =
> <mikeroet@informatik.uni-bremen.de> wrote:
>
>> Sen schrieb:
>>> Hi,
>>> why:
>>> $n =3D count($_GET);
>>> for($i=3D0; $i<$n; $i++)
>>> {
>>> echo $_GET[$i]
>>> }
>>> Doesn't work?
>>> sen
>>
>> If you open index.php?test=3Dhallo, then you can access the value wit=
h =
>> $_GET['test'].
>> Your loop now tries to echo $_GET[0] for example, but you need to ech=
o =
>> $_GET['test'] in order to see anything. :-)
>>
>> If you want to walk through an array, use
>> foreach ($array as $value)
>> {
>> echo $value;
>> }
>
> The difference can be found in indexed arrays (using numbers) or =
> associative arrays (using texts). Using foreach() this difference is =
> overcome.
Yup.
If you really, really want to do it the hard way:
$n =3D count($_GET);
for($i =3D 0;$i < $n;$i++){
echo reset(array_slice($_GET,$i,1));
}
But that's just crazy.... foreach it is :P.
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|