Using file()
Posted: Wed Aug 06, 2014 11:04 am
Hi everyone,
I am learning about how to open a file with the file() function. file() stores the info as an array. So far, i get that - each line of info in the file because a separate value in the array. The part that I am not getting is how it is being displayed using 'foreach' shown in the coding below. Please notice the use of '.='
I understand that the array values need to be appended, and '.' is concatenation, but i just can't seem to get my head around that '.=' thingy. Here's the code:
I found the '.=' again in some Wordpress coding ...
I am learning about how to open a file with the file() function. file() stores the info as an array. So far, i get that - each line of info in the file because a separate value in the array. The part that I am not getting is how it is being displayed using 'foreach' shown in the coding below. Please notice the use of '.='
I understand that the array values need to be appended, and '.' is concatenation, but i just can't seem to get my head around that '.=' thingy. Here's the code:
Code: Select all
$fileName = "sonnet76.txt";
$sonnet = file($fileName);
foreach($sonnet as $text){
$text = str_replace("r", "<b>w</b>", $text);
$text = str_replace("l", "<b>w</b>", $text);
$story .= $text . "<br />";
}
print $story;
I found the '.=' again in some Wordpress coding ...
Code: Select all
if ( 'cyrillic' == $subset )
$subsets .= ',cyrillic,cyrillic-ext';
elseif ( 'greek' == $subset )
$subsets .= ',greek,greek-ext';
elseif ( 'vietnamese' == $subset )
$subsets .= ',vietnamese';