search

Home  >  Q&A  >  body text

Do arrays in PHP only obtain values ​​based on the keys in the array? Are subscripts useless to PHP?

 $arrayName3=array("name"=>"张三","age"=>18,"gnner"=>"男",0=>12);

echo $arrayName3[1];

Notice: Undefined offset: 1 in /data/lab/3fkt36wm/index.php on line 15

zlzl2050 days ago1193

reply all(2)I'll reply

  • angryTom

    angryTom2019-07-15 09:59:18

    Your array is an associative array, not an index array. Therefore, you cannot use subscripts to access elements in the array, you can only access them through the key names you set

    reply
    0
  • zl

    emmm, I understand. Thanks

    zl · 2019-07-15 10:16:10
  • Cancelreply