Try putting a semicolon after: $files = glob('/tmp/sess'); Verstuurd vanaf mijn iPad > Op 14 jun. 2014 om 21:19 heeft hadi <almarzuki2011@xxxxxxxxxxx> het volgende geschreven: > > Paladin, > >> Hi, take a look at glob function.. you cannot loop over filesystem > directly. use >> glob and loop over it's result > > It's not working it giving error check my code after modifying > > (PHP Parse error: syntax error, unexpected T_FOREACH in > /var/www/html/phptest/search2.php on line 6 > > Parse error: syntax error, unexpected T_FOREACH in > /var/www/html/phptest/search2.php on line 6) > > > $files = glob('/tmp/sess*') > > foreach ($files as $file) > > { > > if (time()- filemtime($ip) > 60) > > { > > $old = 'hadi'; > > $filename = '$file'; > > $file1 = file_get_contents($filename); > > strpos($file1, $old); > > unlink ($filename); > > break(); > > } > } > > ?> > >>> On , hadi 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 >>> [..] >> >> Hi, take a look at glob function.. you cannot loop over filesystem > directly. use >> glob and loop over it's result >> >> you will want something like >> >> <?php >> >> $files = glob('/tmp/sess*') >> >> foreach ($files as $file) { >> // do something with file $file >> } >> >> Hope it'll help, >> Paladin >> -- >> There are only two hard things in Computer Science: >> cache invalidation, naming things and off-by-one errors. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php