Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
$array = ["foo", "bar"]; foreach($array as $key => $value$key=>$value) { // $key = 0, $value = foo // On next iteration: $key = 1, $value =do barstuff }
$key is the index of each $array itemelement
$key
$array
$array = ["foo", "bar"]; foreach($array as $key => $value) { // $key = 0, $value = foo // On next iteration: $key = 1, $value = bar }
$key is the index of each $array item
foreach($array as $key=>$value) { // do stuff }
$key is the index of each $array element
$array = ["foo", "bar"]; foreach($array as $key=>$value$key => $value) { // do$key stuff= 0, $value = foo // On next iteration: $key = 1, $value = bar }
$key is the index of each $array elementitem
$key$key is the index of each $array$array element