본문 바로가기
뚝딱뚝딱웹공장

for 문

by 대류 2005. 7. 20.

$dr1=stripslashes($data[dr1]);


for($i=1;$i<=10;$i++) {

      ${'dr'.$i}=$data['dr'.$i]=stripslashes($data['dr'.$i]);

   }


if($dr1)$dr1="<a class=url href='$dr1' target=_blank>$dr1</a>";


for($i=1;$i<=10;$i++) {

if(${'dr'.$i}) ${'dr'.$i} = '<a class=url href='.${'dr'.$i}.'" target=_blank>'.${'dr'.$i}.'</a>';

}


$hide_sitelink1_start


${'hide_sitelink'.$i.'_start'}


{ $hide_sitelink1_start="<!--";$hide_sitelink1_end="-->";}


{ ${'hide_sitelink'.$i.'_start'}="<!--";${'hide_sitelink'.$i.'_end'}="-->";}


학습용 소스


<?php

$temp['file1_name'] = 'file1_name';

$temp['file2_name'] = 'file2_name';

$temp['file3_name'] = 'file3_name';

$temp['file4_name'] = 'file4_name';

$temp['file5_name'] = 'file5_name';

$temp['file6_name'] = 'file6_name';


$dream1 = 'dream1';

$dream2 = 'dream2';

$dream3 = 'dream3';

$dream4 = 'dream4';

$dream5 = 'dream5';

$dream6 = 'dream6';


for($i=1;$i<=6;$i++) {

// 1

${'dr'.$i} = '<tag option="'.$temp['file'.$i.'_name'].'">'.${'dream'.$i}.'</tag>';

// 2

//${'dr'.$i} = "<tag option='".$temp['file'.$i.'_name']."'>".${'dream'.$i}."</tag>";

// 3

// ${"dr".$i} = "<tag option='".$temp["file".$i."_name"]."'>".${"dream".$i}."</tag>";

}


echo '<xmp>';

echo $dr1;

echo "\n";

echo $dr2;

echo "\n";

echo $dr3;

echo "\n";

echo $dr4;

echo "\n";

echo $dr5;

echo "\n";

echo $dr6;

?>

댓글