簡體   English   中英

php array:如何在關聯數組中訪問“ $ key-1”?

[英]php array : how to access the “$key-1” in an associative array?

我有一組條件的現有foreach,我想保持原樣,並添加結束日期,該日期是該行的開始日期+一天之前

我如何訪問“ $ line-1”來執行以下操作:

foreach($tab as $line){
       if the line before with $line[beginning_date] exists
           $line[end_date]=   the line before with $line[beginning_date] value +1
 }

夠好了?

$theLineBefore = null;
foreach($tab as $line){
       if the line before with $line[beginning_date] exists
           $line[end_date]=   the line before with $line[beginning_date] value +1
  $theLineBefore = $line;
 }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM