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:[EMAIL PROTECTED]]
Sent: Monday, February 26, 2001 8:17 AM
To: [EMAIL PROTECTED]
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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to