PHP foreach that returns keys only

前端 未结 7 856
逝去的感伤
逝去的感伤 2020-12-29 18:51

Theoretical question that perhaps does not make any sense but still, maybe there is a clever answer.

I want to iterate through array and get its keys and to somethin

7条回答
  •  甜味超标
    2020-12-29 19:12

    loop to avoid a foreach in a while.

    $a = ['1','A','B','12','ui'];
    
     while(true) { sleep(1);
        $b = next($a) ? current($a): reset($a);
        echo key($a) , ':' , $b , PHP_EOL;
     }
    

提交回复
热议问题