Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. If you want the CSS for the slideshow example, it is embedded in the HTML file not in a separate CSS file.
  2. For the regex approach, you could just use /^\S+\s+/ (using \S instead of [^\s]).
  3. Maybe I'm missing something obvious but you seem to be doing more work than might be necessary. <?php // redirect if only one option if (count($rates_array) == 1) { $rate = current($rates_array); if (count($rate) === 1) { $_SESSION['checkout_data']['shipping_fee'] = current($rate); $_SESSION['checkout_data']['shipping_type'] = key($rate); header("Location: ".secure_base_url()."checkout/card_accept/one_ship".SITE_FILE_EXTENSION, TRUE, 302); } }
  4. Good, good. You really wouldn't want to delve into checking for leap year dates (though it's possible)!
  5. The OP needs to be aware that this won't work properly for Februaries in leap years (the next being 2012). If that's not a concern then the regex above is a good starting point. It could also be shortened further (you're doing a great job thus far; 217 down to 125 characters) if you feel like it.
  6. This needs amending, as of PHP 5.1.3 the bundled PCRE library was 6.6 (previously 6.2 if I'm reading the logs correctly). From that version onwards, script names like Arabic, Greek and Latin are available. Of course, servers/hosts might not be using the bundled library so check which version of the library you're using (phpinfo() will tell you). Please file a "Documentation problem" bug report (http://bugs.php.net/report.php) and someone will look into changing it.
  7. Oops. It was late and was only running on half-steam, my apologies.
  8. Use preg_quote on the prefix and suffix strings to help prevent any conflicting characters that might be in there. Also, your pattern (the entire first argument to preg_match) needs delimiters at the start and end, the default is a forward-slash (/) character. The string containing the "pattern" probably does not need ^ nor $ and almost certainly doesn't need the /ix in it (that last bit should probably be right at the very end of everything. Assuming your prefix, expression and suffic are correct then it's likely you'd rather want: Pattern (just removed bits from the start/end): (http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)? Code: $regex = '/' . preg_quote($prefix) . '(' . $pattern . ')' . preg_quote($suffix) . '/ix'; echo $regex; // Just to see what it looks like preg_match($regex, $subject, $match); Hopefully that'll help a bit, if not just ask.
  9. There are no special "PHP headers" sent (unless you define them yourself, not by default) informing remote sites that it is PHP grabbing the file rather than a normal person via a browser. However (again by default) PHP will not send the same headers that a browser might. The most usual difference is that no User-Agent header is sent from PHP scripts. You can send one using, as Crayon Violent so succinctly pointed out, cURL, or you can continue using fopen and provide a stream context specifying the user agent header to send. Useful links for the latter include: http://php.net/fopen (see 4th parameter) http://php.net/stream_context_create (to create a stream context) http://php.net/context.http (options for a HTTP stream context) http://php.net/filesystem.configuration#ini.user-agent (ini setting for the default UA to send from fopen, file_get_contents, etc.)
  10. Original $tn = ereg_replace(" ", "_", $template_name); $tn = ereg_replace(".html", "", $tn); $tn = ereg_replace(".htm", "", $tn); $f = ereg_replace(" ", "_", $filesToAdd_v); $f = ereg_replace(".html", "", $f); $f = ereg_replace(".htm", "", $f); One-liner regular expressions $tn = preg_replace(array("/ /", "/\.html?/"), array("_", ""), $template_name); $f = preg_replace(array("/ /", "/\.html?/"), array("_", ""), $filesToAdd_v); String replacements $tn = str_replace(array(" ", ".html", ".htm"), array("_", "", ""), $template_name); $f = str_replace(array(" ", ".html", ".htm"), array("_", "", ""), $filesToAdd_v); One-liner list($tn, $f) = str_replace(array(" ", ".html", ".htm"), array("_", "", ""), array($template_name, $filesToAdd_v));
  11. I haven't thought about it too much, but this doesn't feel like a comfortable fit for regex. Why not just use other date parsing/generating methods (the date or DateTime extensions)?
  12. A couple of things; The prefix does not appear to be in the string that you provided. The suffix is, but the prefix not. Your regular expression only looks for a single character (from the list you provide) between the prefix and suffix. You probably want to use a quantifier to ask for more than one matching character.
  13. You can use the date function to get the date in whatever format you like.
  14. The relevant page in the manual is: http://php.net/operators.errorcontrol
  15. Looks like a slight CSS issue, there are supposed to be two columns (Tutorials and Blog Posts)
  16. $subject = "1252user:100&age:23"; preg_match('/user:\d+/', $subject, $match); echo $match[0];
  17. Your specification of max/min is in the wrong format, it needs to be array("options" => array("min_range" => $min, "max_range" => $max))
  18. Combine them both into a single if statement using && or AND.
  19. You didn't just copy/paste my code did you?
  20. Be warned that by missing the $day parameter out, it will assume the current day. When it comes to the end of a month (anything after the 29th) you'll run into trouble since there is no 30th of some months (february will suffer even more). For example, if today was the 31st then the list of months would be :January::March::March::May::May::July::July::August::October::October::December::December:. Best just stick a 1 into the $day parameter.
  21. echo "Link = " . $set['link'] ", E-mail = " . $set['email'] . "<br/>"; // look here ^ missing period/dot between ] and "
  22. The email filter will only remove the forward- and backslash characters* from that address. All it does is remove disallowed characters from the string, it makes no attempt to validate it (which can be done with FILTER_VALIDATE_EMAIL). Characters that will not get deleted by the sanitizing filter are a-zA-Z0-9"!#$%&'*+-=?^_`{|}~@.[] * the forward slash / was only disallowed very recently so is likely to be allowed by your version of PHP. As for "Name" or "Address" there is no universal pattern to those, it is up to you to decide what you want to allow for those types of values.
  23. Awesome, ta very much.
  24. If it is a really large file, you won't be wanting to load it all into memory at once. How large is "large"?
  25. Hi freaks I'm just wondering if it is at all possible to perhaps allow your RSS feeds for the forums to contain the full text of the post, currently only an excerpt is shown (except for very short posts). If I'm missing some query parameter to give me it, do feel free to point that out (whilst pointing and laughing). Cheerybye
×
×
  • 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.