1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Displaying search result correctly.

Discussion in 'PHP' started by andytan91, Aug 18, 2010.

  1. #1
    Hello guys i am doing a search function whereby users can check whether a setting is Pass or Fail in a text file. Currently, i am using if statement and && operator to do the search function. However, i notice there is a constraint whereby if the second preg_match function doesn't find the string, it won't display the text file.

    I have trouble displaying the filename because if that particular string exist and the others don't, it wont display the file. Ultimately, i want the search function to display the filename if it matches just one preg_match function regardless whether other preg_match function in the if statement can find the other string or not..

    Example: User wants to find Service Pack string and Maximum Password Age string which contain "Pass". However, the text file does not contain Audit Account Logon Events" string. Hence, the third preg_match function will not display the file.

    Hence, i am looking for suggestion regarding which php function can i use? Thanks alot!




    Sample text Below
    Service Pack Requirement: Fail
    Current Settings for Service Pack Requirement: Disabled
    Maximum Password Age Requirement: Fail
    Current Settings for Maximum Password Age Requirement: Enabled
    Minimum Password Length: Pass
    Current Settings for Minimum Password Length Requirement: Enabled

    Search function code Below
    if ((preg_match("/\bService Pack Requirement:(.*)./", $allFiles)) && (preg_match("/\bMaximum Password Age Requirement:(.*)./", $allFiles))
    && (preg_match("/\bMinimum Password Length:(.*)./", $allFiles)) && (preg_match("/\bAudit Account Logon Events:(.*)./", $allFiles))
    {
    echo "<a href=\"$file\" target=\"_blank\"> $file </a><br />";
    }
    PHP:
     
    andytan91, Aug 18, 2010 IP