PHP Find String

All,

I am fairly new to PHP but require assistance in being able to find a string from a .conf file.

For example, I have a tac_plus.conf file and I would like to search the .conf file and list all lines that equal “user = username”

If your .conf file is a plain text file, you can do something like this:
[php]<?php
$username = ‘test’;

$lines = file(‘tac_plus.conf’);
if(count($lines)) foreach($lines as $line){
if(strpos($line,‘user = ‘.$username)!==false) echo $line.’
’;
}
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service