PHP - Php Wildcard?
Hello,
I am using this PHP script which needs to open several different files with similar names and extensions. This means: fopen(file_1.txt); However, I have about 300 of those files which I need to open and I don't want to rename them one by one. PERL had this awesome feature where you could create a variable with an asterix (wildcard) which would then find anything matching, using a wildcard. Something like: fopen(file_*.txt); ^Would open all files which had file_SOMETHING.txt in them. So is there anything like this in PHP? thanks in advance! Similar Tutorials<?php $title="juni/ngats.co.nr/hehe"; if ($title==([^/\.]+)/ngats.([^/\.]+).nr/([^/\.]+)) { echo it works; } whats wrong here? is it the wildcard? what do i need to do? it says it has errors with [... and then if i remove [] it will point out an error on ^ I would like some advice from someone who already has the quick answer. User uses a form (drop down) to define a variable in their search of the db. PHP/MYSQL Choices are ALL, A, B, C. EXAMPLE1 They choose B. $variable = 'B' SELECT .... WHERE.... x table value = $variable (equals B) All works perfectly. EXAMPLE2 Now if they chose ALL (or don't chose), I have a problem. They choose nothing (which should be ALL records). I need it to go back to having no WHERE portion of the sql command, or a WHERE that pulls all records. They choose nothing. $ variable = 'ALL' SELECT ... WHERE... x table value = $variable (which now equals ALL) I thought % was a wildcard but doesn't work. This seems simple... but eludes me. What should I use for a variable value if there is NO selection or ALL selection???? The WHERE x table value = has to equal SOMETHING, right? Should I be using an IF THEN to zap the line if it equals "all"? Any advice would be helpful! Thanks! Hello guys i have been trying to find an alternative file function to read multiple files into an array. My aim is to preg_replace every file in directory starting with Audit_Report with the font colours...i have been googling it for like 2 hours and the closest answer i can get to is using the glob() function but it doesn't work for me still. I would like you guys to give me suggestions if you can..thanks!! <?php $file = "Audit_Report.(SEAN).(192.168.199.129).txt"; $lines = file($file); foreach ($lines as $line) { $string = $line; $patterns = array(); $patterns[0] = '/\bPass\b/'; $patterns[1] = '/\bFail\b/'; $patterns[2]='/\b============ Major Audit and Account Policies============ \b/'; $replacements = array(); $replacements[1] = "<font color=red>Fail</font>"; $replacements[0] = "<font color=green>Pass</font>"; $replacements[2] = "<br><b>==== Major Audit and Account Policies====</b>"; ksort($patterns); ksort($replacements); $a = preg_replace($patterns, $replacements, $string); echo "$a<br />\n"; file_put_contents(basename($file, substr($file, strpos($file, '.'))) . ".html","$a<br />\n", FILE_APPEND) or die("Cannot write file"); } ?> My service allows users to generate subdomains based off their username(testguy.mydomain.com). I've created a wildcard subdomain for this, so the dynamic subdomains work wonderfully.
I've added a parked domain where my domain is supposed to mirror the given subdomain. However, when I go to the domain.com, it redirects to the subdomain, changing the URL in the address bar. Any ideas?
Or if there a better way to mirror a subdomain while showing the original domain in the address bar?
Edited by fitguydan, 12 June 2014 - 11:57 PM. I tried many ways but unable to pass sessions to virtual subdomains on my site.. I edited ihi.ini file and included Code: [Select] session.cookie_domain = .mydomain.com I like to add that session is active on my main domain for www.mydomain.com only.. So how do I pass sessions for WWW to other subdomains ? Thanks n Advance Hi, I have a page on my Intranet which lists a bunch of install files (for example, Microsoft Office), which are stored in the same directory structure as the site itself. I also have a duplicate installs folder structure in another office, on their local server. I want to make it so that the link changes, depending on which office the user is in. To simplify: If (user is in London) display London link else display Blackpool link I've been trying to make it work via IP Address. The IP range in London is 10.44.6.* However, I can't make the script work with a wildcard (it works fine if I put a specific address in). The code I have so far is: Code: [Select] <?php $ip=$_SERVER['REMOTE_ADDR']; if ($ip == '10.44.6.*') { ?><a href="link1.php">Click Here</a><?php } else { ?><a href="link2.php">Click Here</a><?php }; ?> I think it may be an obvious solution, but if some kind person could perhaps point out my mistakes? Thanks, Dave I am trying to make a simplified query by example search form for my website. I would like to allow my users to do more complicated queries from one my prospects table. The user will be able to search by 1 or more field(s), select the operator for each field & enter the search value for each field. The advanced_search .php file is below: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Advanced Query</title> </head> <body> <form name="form1" method="post" action="do_advanced_search.php"> <table border="0" cellspacing="5" cellpadding="5"> <tr> <th>Field Name</th> <th>Operator</th> <th>Value</th> </tr> <tr> <td><input name="company_name" type="text" id="company_name" value="Company Name" readonly="readonly" /></td> <td><select name="company_operator" size="1" id="company_operator"> <option value="=" selected="selected">=</option> <option value="<>">Not Equal</option> <option value="Like %...%">Like %...%</option> </select></td> <td><input type="text" name="company_value" id="company_value" /></td> </tr> <tr> <td><input name="state" type="text" id="state" value="State" readonly="readonly"/></td> <td><select name="state_operator" size="1" id="state_operator"> <option value="=" selected="selected">=</option> <option value="<>">Not Equal</option> <option value="Like %...%">Like %...%</option> </select></td> <td><input type="text" name="state_value" id="state_value" /></td> </tr> <tr> <td><label> <input name="County" type="text" id="County" value="County" readonly="readonly" /> </label></td> <td><select name="county_operator" size="1" id="county_operator"> <option value="=" selected="selected">=</option> <option value="<>">Not Equal</option> <option value="Like %...%">Like %...%</option> </select></td> <td><input type="text" name="county_value" id="county_value" /></td> </tr> <tr> <td><input name="city" type="text" id="city" value="City" readonly="readonly" /></td> <td><select name="city_operator" size="1" id="city_operator"> <option value="=" selected="selected">=</option> <option value="<>">Not Equal</option> <option value="Like %...%">Like %...%</option> </select></td> <td><input type="text" name="city_value" id="city_value" /></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="button" id="button" value="Search" /> </label></td> <td> </td> </tr> </table> </form> </body> </html> The do_advanced_search.php is below: $connection=mysql_connect($servername,$dbusername,$dbpassword); $db=mysql_select_db($dbname,$connection) or die(mysql_error()); $sql=mysql_query("SELECT * FROM smf_prospects where companyname '". $_POST['company_operator'] ."' '" . $_POST['company_value'] ."' AND state '" . $_POST['state_operator'] ."' '" . $_POST['company_value'] ."' AND county '". $_POST['county_operator'] ."' '" . $_POST['county_value'] . "'); echo $sql; $result=mysql_query($sql,$connection) or die(mysql_error()); while($row=mysql_fetch_array($result)) { $comapanyname= $row['companyname']; $state=$row['state']; $county=$row['county']; } echo $companyname; echo $state; echo $county; ?> Any help would be greatly appreciated. I will poet a completed version of this once it is finished. Thank you, Terry Mullins |