How do I output the current array key?

Hello! Broke the head, for example, code like this:
$ar = array('a', 'b', 'c', 'd');
foreach($ar as $arr){
 if($arr == 'c'){
 //here I output the key of the current array element 

When iterating array foritem need to get the current array key. Please tell me how to do it? Googled examples with while loop, but I need c foreach.
June 10th 19 at 15:43
2 answers
June 10th 19 at 15:45
June 10th 19 at 15:47
foreach ($ar as $key => $arr) {

Where $key will be the key.

Find more questions by tags PHP