Re: for loop not working
| From: | Shawn McKenzie | Date: | Sat, 14 Jun 2014 19:49:31 +0000 |
| Subject: | Re: for loop not working | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323462@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":
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();
>
> }
> }
>
> ?>
>
>
>