1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| <?php
setlocale(LC_ALL, 'fr_FR');
// remove duplicates
$jj = array_unique($jj);
foreach($jj as $yeah){
// you have to select the date atm, not to clever need to think
foreach($hr as $date){
$date_op = substr(str_replace('#','',$date),0,10);
if(strstr($date_op,$yeah)){
$calc[] = str_replace(array('#',' ',"\n"),array('',':',''),$date);
}
}
// find out the first and last value to calculate distance apart
$st_ex = multiexplode(array('-',':'),$calc[0]);
$start = mktime($st_ex[3],$st_ex[4],$st_ex[5],$st_ex[1],$st_ex[0],$st_ex[2]);
$sstart = mktime($st_ex[3],$st_ex[4],$st_ex[5],$st_ex[1],$st_ex[0],$st_ex[2]);
$st_ex = multiexplode(array('-',':'),end($calc));
$end = mktime($st_ex[3],$st_ex[4],$st_ex[5],$st_ex[1],$st_ex[0],$st_ex[2]);
// compile date
echo '<p>'.date('l, jS F Y',$sstart).': '.make_date($start,$end).'</p>';
unset($calc);
}
} else {
$num = count(file('hr.txt'));
echo '<style>.Startwork{background:#7FFF24}.Finishwork{background:#FF4040;}input{width:100%;height:90%;font-size:3em;}</style><a href="?print=true">Compilation</a><form method="post"><input type="submit" name="blt" value="'.is_odd($num).'" class="'.str_replace(' ','',is_odd($num)).'" /></form>';
}
function is_odd($num) {
if ($num % 2 == 0) {
return 'Start work';
} else {
return 'Finish work';
}
}
function multiexplode ($delimiters,$string){
$return_array = Array($string);
$d_count = 0;
while (isset($delimiters[$d_count])){
$new_return_array = Array();
foreach($return_array as $el_to_split){
$put_in_new_return_array = explode($delimiters[$d_count],$el_to_split);
foreach($put_in_new_return_array as $substr){
$new_return_array[] = $substr;
}
}
$return_array = $new_return_array; // Replace the previous return array by the next version
$d_count++;
}
return $return_array; // Return the exploded elements
}
function make_date($d1,$d2){
$dateDiff = $d2 - $d1;
$fullDays = floor($dateDiff/(60*60*24));
$fullHours = floor(($dateDiff-($fullDays*60*60*24))/(60*60));
$fullMinutes = floor(($dateDiff-($fullDays*60*60*24)-($fullHours*60*60))/60);
return "<strong>$fullHours</strong> heures et <strong>$fullMinutes</strong> minutes.";
}
?> |
Partager