RE: [PHP] for loop not working
| From: | hadi | Date: | Sat, 14 Jun 2014 20:06:53 +0000 |
| Subject: | RE: [PHP] for loop not working | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323465@lists.php.net to get a copy of this message | ||
> 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":
Im not trying to delete file more than 60 second I just want my code to be
fixed.
I just wanted to delete the file which contain the value "hadi"
> -----Original Message-----
> From: shawn.mckenzie@gmail.com [mailto:shawn.mckenzie@gmail.com] On
> Behalf Of Shawn McKenzie
> Sent: Saturday, June 14, 2014 10:50 PM
> To: hadi
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] 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@hotmail.com> 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: [application/pkcs7-signature] smime.p7s
Attachment: [application/pkcs7-signature] smime.p7s