qadenza:
改行で文字列を爆発することはできませんtxt
ファイル
colors.txt
rgb(15, 255, 255)
rgb(15, 255, 252)
rgb(15, 255, 249)
PHP
$str = file_get_contents('colors.txt');
$arr = explode(PHP_EOL, $str);
$ht = '';
foreach($arr as $el){
$ht .= "<div class='color' style='background:" . $el . "'></div>\n";
}
echo $ht; // nothing visible on page
また、試してみました
$arr = explode('\n', $str);
$arr = explode('\n\r', $str);
$arr = explode('\r\n', $str);
$arr = explode('LF', $str); // LF stands in notepad++
任意のヘルプ?
ダイにAnantシン---アライブ:
使用ファイル()関数:
$str = file('colors.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$ht = '';
foreach($str as $el){
$ht .= "<div class='color' style='background:" . $el . "'></div>\n";
}
echo $ht;