Its possible to search through a txt file? I made a php script that open a txt file and writes on it but now i want to be able to search through the file and find whats it on it. The txt file looks kind of like this ......... ctl00$ctl00$cpMain$cpMain$Box$firs_name=THEIR_NAME ctl00$ctl00$cpMain$cpMain$Box$last_name=THEIR_LAST_NAME ..... Code (markup): What i want to do its that when the user search for their first name it will show them their last name. Its just an example. Sorry for my bad english.
If your text file is laid out exactly the way you have it displayed (two lines for each record) then you could do it like this. Example text file called test.txt. ctl00$ctl00$cpMain$cpMain$Box$firs_name=THEIR_NAME ctl00$ctl00$cpMain$cpMain$Box$last_name=THEIR_LAST_NAME Code (markup): The script: <?php $firstName = "THEIR_NAME"; $theFile = "test.txt"; $fp = fopen($theFile,"r"); while(!feof($fp)) { $line1 = explode("=",fgets($fp)); $line2 = explode("=",fgets($fp)); if(trim($line1[1]) == $firstName) { echo "First Name = ".$line1[1]."<br /> Last Name = ".$line2[1]."<br />"; } } ?> PHP:
hiiii hey u can get all inframtion abt php script in w3schools site it realy very helpful.u can get all kind f script and help i hope this will help u thanks Devid