Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ul>
- <?php
- $values = array();
- $values[] = array('example'=>'example1','date'=>'2020-01-25');
- $values[] = array('example'=>'example2','date'=>'2020-02-25');
- $values[] = array('example'=>'example3','date'=>'2020-03-25');
- $previous = null;
- $pesan=[];
- foreach($values as $i=>$gunawan)
- {
- //echo "<li>".$example['example']." - ".$example['date'];
- $sementara=['date'=>$gunawan['date'], 'selisih'=>0];
- $pesan[]=$sementara;
- /*
- if ($previous !== null) {
- $diff = strtotime($example['date'])-strtotime($previous);
- echo " - ".($diff/(60*60*24))." Hari";
- }
- $previous = $example['date'];
- echo "</li>\n";
- */
- if($i!=0){
- $selisih=strtotime($gunawan['date'])-strtotime($pesan[$i-1]);
- $selisih_hari = $selisih / (60*60*24) ;
- $pesan[$i-1]=$selisih_hari;
- }
- }
- foreach($pesan as $row){
- echo "<li>{$row[date]} - {$row[selisih]}</li>";
- }
- ?>
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement