get previous array values in foreach

后端 未结 7 1439
死守一世寂寞
死守一世寂寞 2021-02-01 23:04

My array :

$arr = array(\"jan\",\"feb\",\"mar\",\"apr\",\"mei\",\"jun\",\"jul\",\"agu\",\"sep\",\"okt\",\"nov\",\"des\");

then i do a foreach<

7条回答
  •  温柔的废话
    2021-02-01 23:30

    foreach($arr as $key => $value){
      if ($key > 0) {
       echo $arr[$key-1];
      }
      echo $value;
    }
    

    See this question and answer.

提交回复
热议问题