RE: [PHP] Making a variable

From: Date: Mon, 26 Feb 2001 16:39:41 +0000
Subject: RE: [PHP] Making a variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41697@lists.php.net to get a copy of this message
you can concatentate the variable inside the foreach loop. foreach (file("$file.txt") as $line) { $data .= ("" . trim(str_replace("'", "''", $line)) . "\n"); } -----Original Message----- From: Clayton Dukes [mailto:cdukes@cdukes.com] Sent: Monday, February 26, 2001 8:17 AM To: php-general@lists.php.net Subject: [PHP] Making a variable How can I make this a variable? ie: foreach (file("$file.txt") as $line) { print ("" . trim(str_replace("'", "''", $line)) . "\n"); } changed to: $data = foreach (file("$file.txt") as $line) { print ("" . trim(str_replace("'", "''", $line)) . "\n"); } Simply adding the $data = in front of it doesn't work, I assume it needs to be enclosed by () or ; or something right? Thanks :-) Clayton Dukes

« previous php.general (#41697) next »