Re: [PHP] read a bunch of files that are in many directors into one string -- oops again

2008-08-07 Thread Micah Gersten
foreach (range(0,22) as $dirNum)

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 *I get this when I run it
 Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
 line *4
 it does not like the *foreach (0..22 as $dirNum)
 Try this:

 $rootPath = '/remote';
 $string = '';
 foreach (0..22 as $dirNum)
 {
 $dir = $rootPath/$dirNum;
 chdir($dir);
 $files = glob(13*);
 foreach ($files as $file)
 {
$string .= file_get_contents($file);
 }
 }

 echo $string;
   
 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com



 Richard Kurth wrote:
  
 Version 5

 First, which version of PHP?  PHP 5 added a lot of features for
 reading
 files.

 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com



 Richard Kurth wrote:
  
  
 I am trying to read a bunch of files that are in many directors into
 one string
 But it will only read one file.
 Every file is a number 134328923 but they all start with 13
 They are in 22 directors named 0 to 22
 How can I make the script look in each directory and read each file
 into a string that is one line after another.
 There is only one line per file they are email address

 $file=/remote/0/13*;
 $data =;
 $fp = fopen($file, r);
 while(!feof($fp)) {
 $data .= fgets($fp, 1024);
 }

 echo $data

 
 
 

   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] read a bunch of files that are in many directors into one string -- oops again

2008-08-07 Thread Richard Kurth

*Now I get  this error
Warning*: chdir() [function.chdir]: No error (errno 0) in
*C:\web\easycontactpro\removeemail.php* on line *7*
Where can I find what errno 0 means
it loops through all the directors but does not process any of the files

foreach (range(0,22) as $dirNum)

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
  

*I get this when I run it
Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
line *4
it does not like the *foreach (0..22 as $dirNum)


Try this:

$rootPath = '/remote';
$string = '';
foreach (0..22 as $dirNum)
{
$dir = $rootPath/$dirNum;
chdir($dir);
$files = glob(13*);
foreach ($files as $file)
{
   $string .= file_get_contents($file);
}
}

echo $string;
  
Thank you,

Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  

Version 5
   


First, which version of PHP?  PHP 5 added a lot of features for
reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
 
  

I am trying to read a bunch of files that are in many directors into
one string
But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file
into a string that is one line after another.
There is only one line per file they are email address

$file=/remote/0/13*;
$data =;
$fp = fopen($file, r);
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data




  


  
  


  




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] read a bunch of files that are in many directors into one string -- oops again

2008-08-07 Thread Micah Gersten
Well, make sure $rootPath is correct for your environment.  Also, add a
slash after the directory name.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 *Now I get  this error
 Warning*: chdir() [function.chdir]: No error (errno 0) in
 *C:\web\easycontactpro\removeemail.php* on line *7*
 Where can I find what errno 0 means
 it loops through all the directors but does not process any of the files
 foreach (range(0,22) as $dirNum)

 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com



 Richard Kurth wrote:
  
 *I get this when I run it
 Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
 line *4
 it does not like the *foreach (0..22 as $dirNum)

 Try this:

 $rootPath = '/remote';
 $string = '';
 foreach (0..22 as $dirNum)
 {
 $dir = $rootPath/$dirNum;
 chdir($dir);
 $files = glob(13*);
 foreach ($files as $file)
 {
$string .= file_get_contents($file);
 }
 }

 echo $string;
   Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com



 Richard Kurth wrote:
  
  
 Version 5
   
 First, which version of PHP?  PHP 5 added a lot of features for
 reading
 files.

 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com



 Richard Kurth wrote:
  
   
 I am trying to read a bunch of files that are in many directors
 into
 one string
 But it will only read one file.
 Every file is a number 134328923 but they all start with 13
 They are in 22 directors named 0 to 22
 How can I make the script look in each directory and read each file
 into a string that is one line after another.
 There is only one line per file they are email address

 $file=/remote/0/13*;
 $data =;
 $fp = fopen($file, r);
 while(!feof($fp)) {
 $data .= fgets($fp, 1024);
 }

 echo $data

 
   
 
 

   




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] read a bunch of files that are in many directors into one string -- oops again

2008-08-07 Thread Richard Kurth

I had to add the full path and it works just fine.
Thanks

Well, make sure $rootPath is correct for your environment.  Also, add a
slash after the directory name.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
  

*Now I get  this error
Warning*: chdir() [function.chdir]: No error (errno 0) in
*C:\web\easycontactpro\removeemail.php* on line *7*
Where can I find what errno 0 means
it loops through all the directors but does not process any of the files


foreach (range(0,22) as $dirNum)

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  

*I get this when I run it
Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
line *4
it does not like the *foreach (0..22 as $dirNum)
   


Try this:

$rootPath = '/remote';
$string = '';
foreach (0..22 as $dirNum)
{
$dir = $rootPath/$dirNum;
chdir($dir);
$files = glob(13*);
foreach ($files as $file)
{
   $string .= file_get_contents($file);
}
}

echo $string;
  Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
 
  

Version 5
  


First, which version of PHP?  PHP 5 added a lot of features for
reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  
  

I am trying to read a bunch of files that are in many directors
into
one string
But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file
into a string that is one line after another.
There is only one line per file they are email address

$file=/remote/0/13*;
$data =;
$fp = fopen($file, r);
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data



  
  



  
  
  





  



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php