dポイントプレゼントキャンペーン実施中!

for文を使って処理するプログラムを作成中ですが、

for ( $i=1; $i<=$count; $i++) {
$「log+$count」 = './test'.$count.'.log';
}

としていくのですが、
「log+$count」
の部分がどうすればいいかわかりません。
最終的に、
$count=5
$log1=./test1.log
$log2=./test2.log
$log3=./test3.log
$log4=./test4.log
$log5=./test5.log

としたいのですが、よくわかりません。
だれかご存知でしょうか?

A 回答 (3件)

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


${"log$i"} = './test'.$i.'.log';
}
これで行けるかと。
    • good
    • 0

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


$log_count = 'log' .$i;
$$log_count = './test'.$i.'.log';
}

$count と $i の使い方が間違ってますので、気をつけてください。($countを使用した場合は常に「5」しか値が入りません)

この回答への補足

あwあわわ間違ってるw
正しくは
for ( $i=1; $i<=$count; $i++) {
$「log+$i」 = './test'.$i.'.log';
}
でしたw

補足日時:2006/08/07 10:56
    • good
    • 0

$log[1] .. $log[5] の配列変数に収めるのでは何か問題があるのでしょうか?

    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!