ShiloVir Posted November 24, 2008 Share Posted November 24, 2008 Sorry for sounding lanmient. but can someone tell me how to search a txt file for the text: "Airbus A318-111 Tarom CFM" notice how its an array looking type thing. I only need the text found between the " and the other " or if there isnt a comma on the line then I need it to find the text after the "=" and to end at the end of the line. in a file that looks like this: [fltsim.0] title=Airbus A318-111 Tarom CFM ui_variation=Tarom sim=pa318-cfm56 model=cfm panel= sound= texture=tarom checklists= description=Presenting the Project Airbus A318-111. Visual model by Andy Warden and Derek Mayer. Base textures by Demetris Themistocleous and Sheldon Fernandes. Flight model by Peter Binamira, Derek Mayer, and Steve Mcbee. Paint by Denis Minaev. Copyright Project Airbus 2008.\n\n\n\n\n\n atc_id=YR-ASD atc_airline=Tarom atc_flight_number=801 ui_manufacturer=Project Airbus ui_type=A318-111 visual_damage=1 atc_heavy=0 HOwever I cant have it find a line number because there could be comments in the script like this: [fltsim.0] // This is a comment. hah. Ima ninja! // This is another comment The following line could also have comma's title="Airbus A318-111 Tarom CFM" ui_variation=Tarom sim=pa318-cfm56 model=cfm panel= sound= texture=tarom checklists= description=Presenting the Project Airbus A318-111. Visual model by Andy Warden and Derek Mayer. Base textures by Demetris Themistocleous and Sheldon Fernandes. Flight model by Peter Binamira, Derek Mayer, and Steve Mcbee. Paint by Denis Minaev. Copyright Project Airbus 2008.\n\n\n\n\n\n atc_id=YR-ASD atc_airline=Tarom atc_flight_number=801 ui_manufacturer=Project Airbus ui_type=A318-111 visual_damage=1 atc_heavy=0 Quote Link to comment https://forums.phpfreaks.com/topic/133986-solved-search-txt-for-type/ Share on other sites More sharing options...
ShiloVir Posted November 24, 2008 Author Share Posted November 24, 2008 Still? Anyone know how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/133986-solved-search-txt-for-type/#findComment-697714 Share on other sites More sharing options...
flyhoney Posted November 24, 2008 Share Posted November 24, 2008 Here is some code to give you a start: <?php $looking_for = 'Airbus A318-111 Tarom CFM'; // read file into array $config_file = file('textfile.txt'); // check each line of file foreach ($config_file as $config) { list($key, $value) = split('=', $config); if (strpos($value, $looking_for) !== false) { // found! } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/133986-solved-search-txt-for-type/#findComment-697859 Share on other sites More sharing options...
ShiloVir Posted November 24, 2008 Author Share Posted November 24, 2008 wow. Thank you. That wasnt just a start. but it was a Topic Solved. Quote Link to comment https://forums.phpfreaks.com/topic/133986-solved-search-txt-for-type/#findComment-697883 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.