Directory / File Searching

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Riau
Forum Newbie
Posts: 3
Joined: Wed Nov 19, 2003 5:06 am
Location: UK

Directory / File Searching

Post by Riau »

Hi,

I'm currently working on a project that requires me to use PHP to handle and read INI files...I only started learning PHP at the beginning of the week, and I have encountered a problem. I need a way to search a directory full of INI files for a specific string in one of the files, and I'm not sure how to go about this. As far as I know, all of the INI's are going to have to be parsed to be searched...I can handle that, I'm just not sure how to go about the searching itself.

A search of the PHP Manual hasn't offered many hints so far...

I'd be grateful for any ideas and assistance.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

have a look at this in the manual

http://se.php.net/manual/en/function.strstr.php

Mark
Riau
Forum Newbie
Posts: 3
Joined: Wed Nov 19, 2003 5:06 am
Location: UK

Post by Riau »

Thanks. That helps with the searching. Another thing...how do I tell PHP to search all the INI's in the directory...would i need readdir for that? Seems simple...but I don't know how to do it :/
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

http://php.net/opendir

use opendir(), then readdir() and in the loop, you can read each file. Anyhow, you can read the comments from other users on the functions, you'll learn a lot from them.

-Nay
Riau
Forum Newbie
Posts: 3
Joined: Wed Nov 19, 2003 5:06 am
Location: UK

Post by Riau »

Thanks for the help :D
Post Reply