Can items in PHP associative arrays not be accessed numerically (i.e. by index)?

后端 未结 6 1653
清酒与你
清酒与你 2021-01-06 08:26

I\'m trying to understand why, on my page with a query string, the code:

echo \"Item count = \" . count($_GET);
echo \"First item = \" . $_         


        
6条回答
  •  鱼传尺愫
    2021-01-06 09:12

    As another weird workaround, you can access the very first element using:

     print $_GET[key($_GET)];
    

    This utilizes the internal array pointer, like reset/end/current(), could be useful in an each() loop.

提交回复
热议问题