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

后端 未结 3 1084
春和景丽
春和景丽 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条回答
  •  灰色年华
    2021-01-29 12:44

    Yes the explanation given by BoltClock is right & i would suggest you to manually try too. You have missed $before array name in the foreach statement

    foreach($arr_name as $key=>$value) echo $value ?>

提交回复
热议问题