Does foreach() work for non-numerical array keys?

后端 未结 3 1051
春和景丽
春和景丽 2021-01-29 12:03

I was wondering if foreach() works when the array looks like this:

  • arr_name[eggs] = something
  • arr_name[pencil] = something else

Will foreac

3条回答
  •  闹比i
    闹比i (楼主)
    2021-01-29 12:43

    Yes, PHP has no real distinction between arrays with numeric vs non-numeric keys. They're all simply arrays as far as PHP is concerned.

提交回复
热议问题