for 문이 어떻게 되나요~~
본문
다음과 같은 것을 for 문으로 표현하려는데 도통 에러만 나고 되질 않네요~~ 어디가 잘못인가요?
$latest_out_01 = $cf_bs02['1'];
$latest_skin_01 = $cf_bs02['2'];
$latest_board_id_01 = $cf_bs02['3'];
$latest_group_id_01 = $cf_bs02['4'];
$latest_line_number_01 = $cf_bs02['5'];
$latest_text_lenght_01 = $cf_bs02['6'];
$latest_out_02 = $cf_bs02['7'];
$latest_skin_02 = $cf_bs02['8'];
$latest_board_id_02 = $cf_bs02['9'];
$latest_group_id_02 = $cf_bs02['10'];
$latest_line_number_02 = $cf_bs02['11'];
$latest_text_lenght_02 = $cf_bs02['12'];
$latest_out_03 = $cf_bs02['13'];
$latest_skin_03 = $cf_bs02['14'];
$latest_board_id_03 = $cf_bs02['15'];
$latest_group_id_03 = $cf_bs02['16'];
$latest_line_number_03 = $cf_bs02['17'];
$latest_text_lenght_03 = $cf_bs02['18'];
$latest_out_04 = $cf_bs02['19'];
$latest_skin_04 = $cf_bs02['20'];
$latest_board_id_04 = $cf_bs02['21'];
$latest_group_id_04 = $cf_bs02['22'];
$latest_line_number_04 = $cf_bs02['23'];
$latest_text_lenght_04 = $cf_bs02['24'];
$latest_out_05 = $cf_bs02['25'];
$latest_skin_05 = $cf_bs02['26'];
$latest_board_id_05 = $cf_bs02['27'];
$latest_group_id_05 = $cf_bs02['28'];
$latest_line_number_05 = $cf_bs02['29'];
$latest_text_lenght_05 = $cf_bs02['30'];
$latest_out_06 = $cf_bs02['31'];
$latest_skin_06 = $cf_bs02['32'];
$latest_board_id_06 = $cf_bs02['33'];
$latest_group_id_06 = $cf_bs02['34'];
$latest_line_number_06 = $cf_bs02['35'];
$latest_text_lenght_06 = $cf_bs02['36'];
$latest_out_07 = $cf_bs02['37'];
$latest_skin_07 = $cf_bs02['38'];
$latest_board_id_07 = $cf_bs02['39'];
$latest_group_id_07 = $cf_bs02['40'];
$latest_line_number_07 = $cf_bs02['41'];
$latest_text_lenght_07 = $cf_bs02['42'];
위의 내용을 아래와 같이 했습니다
for($j=1;$j<=42;$j+=6)
${"latest_out_0".sprintf('%d', $j+5/6)} = $cf_bs02[$j];
${"latest_skin_0".sprintf('%d', $j+5/6)} = $cf_bs02[$j+1];
${"latest_board_id_0".sprintf('%d', $j+5/6)} = $cf_bs02[$j+2];
${"latest_group_id_0".sprintf('%d', $j+5/6)} = $cf_bs02[$j+3];
${"latest_line_number_0".sprintf('%d', $j+5/6)} = $cf_bs02[$j+4];
${"latest_text_lenght_0".sprintf('%d', $j+5/6)} = $cf_bs02[$j+5];
답변 4
for ($i = 1; $i <= 7; $i++) {
$latest_out[$i] = $cf_bs02[($i - 1) * 6 + 1];
$latest_skin[$i] = $cf_bs02[($i - 1) * 6 + 2];
$latest_board_id[$i] = $cf_bs02[($i - 1) * 6 + 3];
$latest_group_id[$i] = $cf_bs02[($i - 1) * 6 + 4];
$latest_line_number[$i] = $cf_bs02[($i - 1) * 6 + 5];
$latest_text_length[$i] = $cf_bs02[($i - 1) * 6 + 6];
}
들레아빠님 추가 답변 고맙습니다~~ 혼자 공부하자니 맨날 초보 탈출이 안됩니다
감사합니다~~ 위로까지 ~퇴직 백수의 길이 아주 즐겁습니다
처음에 알려주신 것은 이상없이 잘 되는데 아래 제게 올린것 수정해주신 것은 되기는 되는데 아래와 같은 오류가 한줄 뜨네요~~
Warning: Undefined array key 42 in D:\Apache24\htdocs\theme\dw_bootstrap\include\out_option.php on line 138
위의 138라인이
${"latest_text_length_0".(int)(($j + 5) / 6)} = $cf_bs02[$j + 5];
거든요
들레아빠님 감사합니다
답변을 작성하시기 전에 로그인 해주세요.