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

后端 未结 6 1644
清酒与你
清酒与你 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 08:53

    Nope -- they are mapped by key value pairs. You can iterate the they KV pair into an indexed array though:

    foreach($_GET as $key => $value) {
        $getArray[] = $value;
    } 
    

    You can now access the values by index within $getArray.

提交回复
热议问题