Jump to content

[SOLVED] Search txt for type


ShiloVir

Recommended Posts

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

Link to comment
Share on other sites

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!
}
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.