問題
値がNULLでない場合、最新の日付で以前の日付のレコードを表示したい。私はいくつかのことを試しましたが、実際には何も機能しませんでした。以下はコード、実際の望ましい結果です。
論理的には、過去の日付の値を複製して最新の日付に割り当てたいと考えています。どんな助けでも素晴らしいでしょう。前もって感謝します!!
コード
$date = date('m/d/Y',time()+( 1 - date('w'))*24*3600);
$ts = strtotime($date);
$year1 = date('o', $ts);
$week = date('W', $ts);
$date_time_array1 = '';
for($i = 1; $i <= 7; $i++) {
$ts = strtotime($year1.'W'.$week.$i);
$date_time_array1[] = date('d/m/Y', $ts);
}//end for week dates
$gadget_data_type_date1 = array();
$empty = true;
for($i=0;$i<count($date_time_array1);$i++){
$flag = 0;
for($j=0;$j<count($date_time_array);$j++){
if($date_time_array1[$i] == $date_time_array[$j]){
$gadget_data_type_date1[] = $date_time_array1[$i];
$gadget_data_type_value1[] = $gadget_data_type_value[$j];
$flag =1;
}
}
if(!$flag){
$gadget_data_type_date1[] = $date_time_array1[$i];
}
$date_time = $gadget_data_type_date1[$i];
$t = explode("/",$date_time);
if (mktime(0,0,0,$t[1],$t[0],$t[2]) >= $game_starts_on) {
$date1 = date('m/d/Y',strtotime(str_replace("/",".",".$date_time.")));
$dateOneMonthSubtracted = date('n/j/Y', strtotime($date1));
$date_time_parse = "'".$dateOneMonthSubtracted.' UTC'."'";
if($gadget_data_type_value1[$i] != 'null'){
$gadget_data_type_value_value2[$i] = $gadget_data_type_value1[$i];
}else{
$gadget_data_type_value_value2[$i] = 'null';
}//end if check null
if ($gadget_data_type_value_value2[$i] != 'null' && $gadget_data_type_value_value2[$i] != '') {
$empty = false;
}//end if value is blank
$date_time_array2[] = "[Date.parse(".$date_time_parse."), ".$gadget_data_type_value_value2[$i]." ]";
}//end if current date is greater than start date
実結果
[0] => [Date.parse('7/22/2013 UTC'), null ], i=>0
[1] => [Date.parse('7/23/2013 UTC'), 6.8717882122446 ], i=>1
[2] => [Date.parse('7/24/2013 UTC'), 0.3531183025553 ], i=>2
[3] => [Date.parse('7/24/2013 UTC'), 0.070564096031649 ], i=>3
[4] => [Date.parse('7/25/2013 UTC'), null ], i=>4
[5] => [Date.parse('7/26/2013 UTC'), 4.374864096031649 ], i=>5
[6] => [Date.parse('7/26/2013 UTC'), 1.263764096031649 ], i=>6
[7] => [Date.parse('7/27/2013 UTC'), null ], i=>7
望ましい結果
[0] => [Date.parse('7/22/2013 UTC'), null ], i=>0
[1] => [Date.parse('7/23/2013 UTC'), 6.8717882122446 ], i=>1
[2] => [Date.parse('7/24/2013 UTC'), 6.8717882122446 ], i=>2
[3] => [Date.parse('7/24/2013 UTC'), 0.3531183025553 ], i=>3
[4] => [Date.parse('7/24/2013 UTC'), 0.070564096031649 ], i=>4
[5] => [Date.parse('7/25/2013 UTC'), null ], i=>5
[6] => [Date.parse('7/26/2013 UTC'), 6.8717882122446 ], i=>6
[7] => [Date.parse('7/26/2013 UTC'), 0.3531183025553 ], i=>7
[8] => [Date.parse('7/26/2013 UTC'), 0.070564096031649 ], i=>8
[9] => [Date.parse('7/26/2013 UTC'), 4.374864096031649 ], i=>9
[10] => [Date.parse('7/26/2013 UTC'), 1.263764096031649 ], i=>10
[11] => [Date.parse('7/27/2013 UTC'), null ], i=>11