= $iDateFrom) { array_push($aryRange, date('Y-m-d', $iDateFrom)); // first entry while ($iDateFrom<$iDateTo) { $iDateFrom += 86400; // add 24 hours array_push($aryRange, date('Y-m-d', $iDateFrom)); } } return $aryRange; } function interval($date1, $date2) { //$date1 = '01-10-2010'; //$date2 = '05-10-2010'; // Declare an empty array $array = array(); // Use strtotime function $variable1 = strtotime($date1); $variable2 = strtotime($date2); // Use for loop to store dates into array // 86400 sec = 24 hrs = 60*60*24 = 1 day for ($currentDate = $variable1; $currentDate <= $variable2; $currentDate += (86400)) { $store = date('Y-m-d', $currentDate); $array[] = $store; } return $array; } function date_formatted($date) { $pieces = explode("-", $date); switch ($pieces[1]) { case 'Jan': $detected_month = "01"; break; case 'Feb': $detected_month = "02"; break; case 'Mar': $detected_month = "03"; break; case 'Apr': $detected_month = "04"; break; case 'May': $detected_month = "05"; break; case 'Jun': $detected_month = "06"; break; case 'Jul': $detected_month = "07"; break; case 'Aug': $detected_month = "08"; break; case 'Sep': $detected_month = "09"; break; case 'Oct': $detected_month = "10"; break; case 'Nov': $detected_month = "11"; break; case 'Dec': $detected_month = "12"; break; } $date_str = $pieces[2] ."-" .$detected_month ."-" .$pieces[0]; return $date_str; } ?>

"; $playerID = "12"; $sql = "SELECT * FROM parties_new WHERE w_playerID = '$playerID' OR b_playerID = '$playerID' ORDER by date asc "; echo $sql; echo "

"; $graph_data = array(); $result = mysql_query($sql); $retid = mysql_query($sql); $id = 1; while ($row = mysql_fetch_array($retid)) { $white = $row["w_playerID"]; $w_name=$row["w_name"]; $black = $row["b_playerID"]; $b_name=$row["b_name"]; $w_rating = $row["w_arating"]; $b_rating = $row["b_arating"]; $w_brating = $row["w_brating"]; $b_brating = $row["b_brating"]; $result=$row["result"]; //$date =$row["date"]; //$date=date("d F Y",$date); //$date_convert = strftime('%d-%m-%Y',strtotime($date)); $timestamp = $row["date"]; $date= date("d F Y",$timestamp); $date_convert = strftime('%d-%h-%Y',strtotime($date)); $diff_w = $w_rating - $w_brating; $diff_b = $b_rating - $b_brating; if($white==$playerID) { if ($result==1) { echo " "; //$pipo =array( $timestamp, $date_convert , $w_rating); $pipo = array("aaa"=>$timestamp,"bbb"=>$date_convert,"ccc"=>$w_rating); } if($result==2) { echo " "; //$pipo =array($timestamp, $date_convert , $w_rating); $pipo = array("aaa"=>$timestamp,"bbb"=>$date_convert,"ccc"=>$w_rating); } if ($result==3) { if($diff_w < 0) { $s1 = ""; $s2 = ""; } else { $s1 = ""; $s2 = ""; } //$pipo =array( $timestamp, $date_convert , $w_rating); $pipo = array("aaa"=>$timestamp,"bbb"=>$date_convert,"ccc"=>$w_rating); echo " "; echo $s1; echo " "; echo $s2; echo " "; } } if ($black==$playerID) { if($result==1) { echo " "; //$pipo =array( $timestamp, $date_convert , $b_rating); $pipo = array("aaa"=>$timestamp,"bbb"=>$date_convert,"ccc"=>$b_rating); } if ($result==2) { echo " "; //$pipo =array( $timestamp, $date_convert , $b_rating); $pipo = array("aaa"=>$timestamp,"bbb"=>$date_convert,"ccc"=>$b_rating); } if ($result==3) { if($diff_b < 0) { $s1 = ""; $s2 = ""; } else { $s1 = ""; $s2 = ""; } //$pipo =array( $timestamp, $date_convert , $b_rating); $pipo = array("aaa"=>$timestamp,"bbb"=>$date_convert,"ccc"=>$b_rating); echo " "; echo $s1; echo " "; echo $s2; echo " "; } } $graph_data[] = $pipo; $id = $id + 1; } ?>
ID Resultat ELO Couleur Adversaire Date
".$id." " ."W1" ." ".$w_rating. " (" .$w_brating ." " .$diff_w ." ) White ".$b_name." ".$b_rating ." (" .$b_brating ." " .$diff_b .") Black ".$date_convert."
".$id." " ."W2" ." ".$w_rating. " (" .$w_brating ." " .$diff_w ." ) White ".$b_name." ".$b_rating ." (" .$b_brating ." " .$diff_b .") Black ".$date_convert."
".$w_rating. " (" .$w_brating ." " .$diff_w .")".$b_name." ".$b_rating ." (" .$b_brating ." " .$diff_b .") Black ".$w_rating. " (" .$w_brating ." " .$diff_w .")".$b_name." ".$b_rating ." (" .$b_brating ." " .$diff_b .") Black
".$id." White".$date."
".$id ." " ."B1" ." ".$b_rating. " (" .$b_brating ." " .$diff_b .") Black ".$w_name." ".$w_rating ." (" .$w_brating ." " .$diff_w .") White ".$date_convert."
".$id ." " ."B2" ." ".$b_rating. " (" .$b_brating ." " .$diff_b.") Black ".$w_name." ".$w_rating ." (" .$w_brating ." " .$diff_w .") White ".$date_convert."
".$b_rating. " (" .$b_brating ." " .$diff_b .")".$w_name." ".$w_rating ." (" .$w_brating ." " .$diff_w .") Black ".$b_rating. " (" .$b_brating ." " .$diff_b .")".$w_name." ".$w_rating ." (" .$w_brating ." " .$diff_w .") Black
".$id." Black".$date."
"; print_r($graph_data); echo ""; /// completer $nb_parties = count($graph_data); echo "NB " .$nb_parties; echo "

"; $start_timestamp = $graph_data[0][0]; $date1 = $graph_data[0][1]; echo "Start " .$date1 ." " .$start_timestamp; echo "

"; $stop_timestamp = $graph_data[$nb_parties-1][0]; $date2 = $graph_data[$nb_parties-1][1]; echo "Stop " .$date2 ." " .$stop_timestamp; echo "

"; //$diff_jours = ($stop_timestamp - $start_timestamp) / 86400; //echo $diff_jours; //echo "

"; // 24 * 60 * 60 //$interval = date_diff($datetime1, $datetime2); $diff = strtotime($date2) - strtotime($date1); //1583877600 //1583964000 // 1 day = 24 hours // 24 * 60 * 60 = 86400 seconds $nb_jours = abs(round($diff / 86400)); $pipo = array(); $time = $start_timestamp; for ($i=0; $i<$nb_jours; $i++) { $pipo[] = array($time,22); $time = $time + 86400; } //var_dump($pipo); //echo "
"; 
	  //print_r($pipo);
	  //echo "
"; // 25-Apr-2014 // 13-Mar-2020 //YYYY-MM-DD $tab = createDateRangeArray("2014-04-25","2020-03-13"); //echo "
"; 
	  //print_r($tab);
	  //echo "
"; /***************************************************************/ //$tab_timestamp = interval("2014-04-25","2020-03-13"); $tab_timestamp = interval( date_formatted($date1), date_formatted($date2)); echo "
"; 
	  print_r($tab_timestamp);
	  echo "
"; $elo_data = array(); for ($i = 0; $i < count($tab)-1; $i++) { $timestamp = strtotime($tab[$i]); $tmp =array( $timestamp, "val"); $elo_data[] = $tmp; } echo "
"; 
	  print_r($elo_data);
	  echo "
"; echo "Find ... " .$elo_data[0][0]; // $key = array_search( $elo_data[0][0] ,$graph_data); //$id = searchForId( $elo_data[0][0], $graph_data); $cpt = 1; for ($i = 0; $i < count($elo_data); $i++) { $find_timestamp = $elo_data[$i][0]; $find = 0; for ($j = 0; $j < count($graph_data); $j++) { $key = "aaa"; if( $graph_data[$j][$key] == $find_timestamp) { echo " +++++ " .$cpt . " " .$find_timestamp . " " .$graph_data[$j]["ccc"]; echo "
"; $cpt++; $find = 1; $elo_data[$i][1] = $graph_data[$j]["ccc"]; break; } } if( $find == 0) { $elo_data[$i][1] = $elo_data[$i-1][1]; } } for ($i = 0; $i < count($elo_data); $i++) { $transformation = date('d-M-Y', $elo_data[$i][0]); $elo_data[$i][0] = $transformation; } echo "
"; 
	  print_r($elo_data);
	  echo "
"; $json = json_encode($elo_data); file_put_contents("elo_data.json", $json); //$key = array_search($elo_data[0][0], array_column($graph_data, 'ccc')); // echo " +++++ " .$key; ///// https://stackoverflow.com/questions/6661530/php-multidimensional-array-search-by-value // https://www.geeksforgeeks.org/php-multidimensional-array-search-by-value/ // https://code.tutsplus.com/tutorials/working-with-php-arrays-in-the-right-way--cms-28606 /* for ($i = 0; $i < count($elo_data); $i++) { echo $elo_data[$i][0]; echo "
"; $timestamp = $elo_data[$i][0]; $key = array_search( , $array); } */ function searchForId($elo, $array) { foreach ($array as $key => $val) { if ($val['ccc'] === $elo) { return $key; } } return null; } ?>