No.. if you are referencing $my_arr['foo'] ==> then $my_array[0] will not be
set.  I think it used to work that way, but it stopped.  If you want to
print it out... use $my_array['foo']

If you don't need the associative referencing, you can just use $my_array[],
which will set $my_array[0]

If you want to print out your array elements in order, use:

while (list ($key, $val) = each ($my_array)) {
    echo "$key => $val<br>";
}

Brian Tanner

Project Manager

Zaam Internet Solutions

Toll Free: 1-866-225-2675

[EMAIL PROTECTED]

http://www.zaam.com





"CC Zona" <[EMAIL PROTECTED]> wrote in message
9hico0$l4l$[EMAIL PROTECTED]">news:9hico0$l4l$[EMAIL PROTECTED]...
> This is weird.  Did I only imagine that PHP allows numerical referencing
of
> associative array elements?  'Cuz suddenly the parser is calling all the
> numerical references "undefined".
>
> ex.
>    $my_arr['foo']='first';
>    $my_arr['bar']='second';
>    $my_arr['more']='third';
>
>    echo "<p>" . $my_arr[0] . "</p>\n";
>    echo "<p>" . $my_arr[1] . "</p>\n";
>    echo "<p>" . $my_arr[2] . "</p>\n";
>
>    for($i=0;$i<count($my_arr);$i++)
>       {
>       echo "<p>" . $my_arr[$i] . "</p>\n";
>       }
>
> ex.
>    $my_arr=array(
>    'foo'=>'first',
>    'bar'=>'second',
>    'more'=>'third'
>    );
>
>    echo "<p>" . $my_arr[0] . "</p>\n";
>    echo "<p>" . $my_arr[1] . "</p>\n";
>    echo "<p>" . $my_arr[2] . "</p>\n";
>
>    for($i=0;$i<count($my_arr);$i++)
>       {
>       echo "<p>" . $my_arr[$i] . "</p>\n";
>       }
>
> The above spits out nothing but a page full of "undefined offset" errors.
> I can't find anything in the arrays chapter, nor in the array function
> reference, to explain why the numerical referencing would've stopped
> working.  This *should* work, right?  So why would it not be working now?
>
> --
> CC
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to