Array key code
Friday, September 2nd, 2005 | Life
Ok, so lets say you want to loop through an array using foreach but you don’t want to show values, you want to show keys, or you want to show both. Use the following code:
foreach($array as $key => $val) {
Then you can access value via $val and the key via $key.
Ok, so lets say you want to loop through an array using foreach but you don’t want to show values, you want to show keys, or you want to show both. Use the following code:
foreach($array as $key => $val) {
Then you can access value via $val and the key via $key.