RE: for loop not working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> foreach(glob('/temp/sess/*') as $file) {
>     if(time() - filemtime($file) > 60) {
>         $old = 'hadi';
>         $content = file_get_contents($file);
>         if(strpos($content, $old) !== false) {
>             unlink($file);
>         }
>     }
> }

Your code working think you.

> -----Original Message-----
> From: shawn.mckenzie@xxxxxxxxx [mailto:shawn.mckenzie@xxxxxxxxx] On
> Behalf Of Shawn McKenzie
> Sent: Saturday, June 14, 2014 10:50 PM
> To: hadi
> Cc: php-general@xxxxxxxxxxxxx
> Subject: Re:  for loop not working
>
> You'll need to outline exactly what you are trying to do as that is barely 
> PHP
> code and makes little sense.  Have you heard of http://www.php.net?
>  Here is a best guess to delete files modified more than 60 seconds that
> contain "hadi":
>
> foreach(glob('/temp/sess/*') as $file) {
>     if(time() - filemtime($file) > 60) {
>         $old = 'hadi';
>         $content = file_get_contents($file);
>         if(strpos($content, $old) !== false) {
>             unlink($file);
>         }
>     }
> }
>
> -Shawn
>
>
> On Sat, Jun 14, 2014 at 1:54 PM, hadi <almarzuki2011@xxxxxxxxxxx> wrote:
>
> > Hi ,
> >
> > Can someone help me to fix my code. It throwing error. I couldn't
> > determine how to do the for loop.
> >
> > Here is my code
> >
> > <?php
> >
> >
> > for ($i; in /tmp/sess*)
> >
> > {
> >
> >
> > if (time()- filemtime($ip) > 60)
> >
> > {
> >
> > $old = 'hadi';
> >
> > $filename = '$i';
> >
> > $file = file_get_contents($filename);
> >
> > strpos($file, $old);
> >
> > unlink ($filename);
> >
> > break();
> >
> > }
> > }
> >
> > ?>
> >
> >
> >

<<attachment: smime.p7s>>


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux