미채택 완료

소스에 직접 배열된 날짜를 텍스트로 읽어들일 수 없을까요?

2017-08-31 (목) 12:37:16 2,316
$mwdayfile = file($file_index."/minwon.txt");
/* for($i=0; $i<count($mwdayfile); $i++) { // 파일 첫 행부터 끝행까지 루프
$mwarr = explode("\n", $mwdayfile[$i]);
$YY_hday = $mwarr[1];
echo $YY_hday;
} */
$YY_hday =array(
'2017-08-15',
'2017-10-03',
'2017-10-04',
'2017-10-05',
'2017-10-06',
'2017-10-09',
'2017-12-25',
'2018-01-01',
'2018-02-15',
'2018-02-16',
'2018-02-17',
'2018-02-18',
'2018-03-01',
);
$timestamp = strtotime($mw_date);
$step = $plus = 0;
while ( $step < 30 )
{
list($d,$w) = explode(' ',date('Y-m-d w',$timestamp));
$timestamp+= 86400;
$step++;
if ( $w%6==0 || in_array($d,$GLOBALS['YY_hday'])){
$plus++; $step--;
}



제가 만들다가 주석처리를 했는데 일단 소스에

저런식으로 년월일이 배열로 들어가 있는데

제가 만든 주석부분은

in_array($d,$GLOBALS['YY_hday']))

여기서 동작을 안하더라고요ㅜㅜ

팁좀 부탁드립니다!!
|

답변 2개 / 댓글 1개

Copy
<?php/*$mwdayfile = file($file_index."/minwon.txt");   for($i=0; $i<count($mwdayfile); $i++) {  // 파일 첫 행부터 끝행까지 루프   $mwarr = explode("\n", $mwdayfile[$i]);   $YY_hday = $mwarr[1];   echo $YY_hday; } */ // 여기서부터 동작 안합니다.// Notice: Undefined variable: f_date$mw_date = $f_date;$YY_hday =array(     '2017-08-15',     '2017-10-03',     '2017-10-04',     '2017-10-05',     '2017-10-06',     '2017-10-09',     '2017-12-25',     '2018-01-01',     '2018-02-15',     '2018-02-16',     '2018-02-17',     '2018-02-18',     '2018-03-01',     ); $timestamp = strtotime($mw_date); $step = $plus = 0; while ( $step < 30 ) {     list($d,$w) = explode(' ',date('Y-m-d w',$timestamp));     $timestamp+= 86400;     $step++;     if ( $w%6==0 || in_array($d,$GLOBALS['YY_hday'])){         $plus++; $step--;     }} ?>
Copy
$YY_hday =array(     '2017-08-15',     '2017-10-03',     '2017-10-04',     '2017-10-05',     '2017-10-06',     '2017-10-09',     '2017-12-25',     '2018-01-01',     '2018-02-15',     '2018-02-16',     '2018-02-17',     '2018-02-18',     '2018-03-01',     ); // 여기서부터 동작 안합니다.// Notice: Undefined variable: mw_date $timestamp = strtotime($mw_date);$step = $plus = 0; while ( $step < 30 ) {     list($d,$w) = explode(' ',date('Y-m-d w',$timestamp));     $timestamp+= 86400;     $step++;     if ( $w%6==0 || in_array($d,$GLOBALS['YY_hday'])){         $plus++; $step--;     }} ?>

답변에 대한 댓글 1개

$mw_date = $f_date;
맨 윗줄이 빠졌었네요

답변을 작성하려면 로그인이 필요합니다.