how to get current index in foreach loop php code example Example: php foreach index foreach($array as $key=>$value) { // do stuff }