Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
i want to do a php script that searches for a string in 250 files in a directory
i can do this but only on 1 file using this code
PHP
<?
$mcc=$_REQUEST[mcc];
$mnc=$_REQUEST[mnc];
$file = "http://******************/data/MEP-09070-001";
$file2=file_get_contents($file);
if(!strpos($file2, "MCC=$mcc
MNC=$mnc")) {
echo "String not found!";
}
else{echo "String found!";
echo "<br />";
$file = str_replace("*************/data/", "", $file);
echo $file;}

?> 


Pleaseeee help
Thanks in advance
Posted
Updated 14-Jun-12 13:52pm
v3
Comments
Sergey Alexandrovich Kryukov 14-Jun-12 20:38pm    
Not a question. (Despite of two question marks which do not mean a question :-) If you can do it in one file, how more file makes any difference?
--SA
krumia 14-Jun-12 21:14pm    
Find a way to iterate through your 250 files and do the same operation to each of them.

You can consider isolating your code into a function for this purpose.

1 solution

If you plan to use the code on the same server which stores information use
PHP
readdir
function in php. More details can be found in the php manual.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900