In the first two examples, you can use key()and current()to assign the necessary values.
$ar = $o->me;
$typ = key($ar);
$val = current($ar);
$out = array('me' => array(), 'mytype' => 2, '_php_class' => null);
$expected = [key($out), current($out)];
In these cases, you can use next()to move the cursor later, but this may not be necessary if the rest of your code does not depend on this.
foreach() $kv .
foreach ($broken as $k => $v) {
$kv = [$k, $v];
}
- ,
list(), .
$this->result = current($this->cache_data);
, $this->cache_data next() , $this->cache_data.
for() for().
reset($array);
for ($i = 0; $i < 30; $i++) {
$id = key($array);
$item = current($array);
// code
next($array);
}