Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. Well, you would probably want to use the %{REQUEST_URI} (or maybe %{REQUEST_FILENAME} or %{SCRIPT_FILENAME} [these are explained in the link I gave you]) and a regular expression which checks to see if it starts with your sub directory.
  2. The function is behaving as expected, it is returning the "page" name based on the SCRIPT_NAME value. What is the output that you would have expected? What does the following give? echo $_SERVER['SCRIPT_NAME'] . '<br>'; echo $_SERVER['SCRIPT_FILENAME'] . '<br>'; echo $_SERVER['REQUEST_URI'] . '<br>'; [ot]Try not to get upset if folks here don't magically answer your problems immediately and fully. This is a help forum but the fact is that most of the time, the questions/problems are vague or not fully explained enough to enable someone to know the solution right away. We ask questions (hopefully the right ones) to delve into the problem in the hope of revealing enough information to form a suitable solution. We're here to work with you, not against you, and that envolves giving and processing information in both directions. If you do want to get upset and start venting at the helper then please don't be offended if the helper decides it's not worth his or her time. [/ot]
  3. Use a RewriteCond[1] to prevent the first rule from working if requesting that sub-directory. If you're stuck after reading about RewriteCond, feel free to ask for further help. [1] http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond
  4. It does not help that your showqblock function is echoing HTML rather than returning it. However, you can grab the echoed text for use in str_replace by changing: $to = showqblock(); To: ob_start(); showqblock(); $to = ob_get_clean();
  5. PHP_EOL is a constant which contains the line-ending character(s) suitable for your server. For example, for a server running on windows it contains the carriage return and newline characters (\r\n) while for a linux box it will contain just the newline character (\n). See some other constants. It added nothing critical to the example code other than placing a line break between each of the dates.
  6. What are the 'formats' that you want to display the date as?
  7. foreach ($images as $image) { echo $dom->saveXML($image) . PHP_EOL; } That will echo all of the image tags.
  8. Hi Aro, welcome to PHPFreaks. Are you a PHP programmer (sounds like a silly question, but we get all sorts here)? Do you use/know/prefer any other languages? Regardless of the answers to those, welcome on board.
  9. In that case, the chances are that you're running some version of PHP 5.2 so the DatePeriod/Interval classes will not be available. The fact that nothing at all is shown means that you should probably turn on error reporting (and displaying; search the forums if you're not sure how to do that) since if you do that, PHP will kindly tell you that those classes are not available. Of course. harristweed's code above should work for you, or you can use something like the code below which uses a for loop to save typing the same thing 10 times, strtotime to move the date forward by some days and date to print a nice representation of each date. for ($i = 0; $i <= 10; $i++) { $date = strtotime("+$i days"); echo date("l jS M Y", $date) . PHP_EOL; }
  10. Are you using PHP 5.3? If so: $today = new DateTime; $interval = new DateInterval('P1D'); $period = new DatePeriod($today, $interval, 10); foreach ($period as $datetime) { echo $datetime->format('l jS M Y') . PHP_EOL; } If you're not so lucky as to to be able to use PHP 5.3 right now, do let us know what is available for you.
  11. Define "destroys" (or "destrozing" for that matter, hehe). Is $a no longer available? Or, what precisely is your problem as you haven't really given much detail to work with.
  12. Seems like an awfully complicated way to do something simple. Would the scheduler have enough information for it to determine whether the previous weekday was either 1 or 0 and whether it was skipped?
  13. Riiigghhhttt. So have you got a full definition of precisely which days behave normally (or, if more concise, which days to skip) as from the posts so far, none of us here have a firm starting point to help you from. Also, could I ask the whole purpose of this exercise?
  14. That's correct, anonymous functions (those created using create_function) do not belong to a class/object so $this is meaningless in that case.
  15. You can't call preg_replace like that (and have it do what you're expecting). The replacement string will effectively be '$1' which of course just wraps the matched value in single quotes. Instead, you should use a callback function with preg_replace_callback like: // The match gets fed into this function which returns the replacement string public function escape_and_quote_match($match) { return "'" . $this->escape_string($match[1]) . "'"; } // How to call preg_replace_callback $result = preg_replace("#<'([^'>]\S+)'>#", array($this, 'escape_and_quote_match'), $string);
  16. Arrays can hold many, many more than 10 items and foreach loops will loop over all of the values (unless told otherwise). What makes you think that the loop is not looping over all of the array?
  17. I'll assume you're somewhat familiar with how preg_match works (since you can find the first already) so will skip a longer explanation. Essentially, you can use a regex which looks for the last set of non-forward-slash characters anchored to the end of the string (using $) like in the example below. $subject = 'dsfdfsfdd/41234/1234324/3243223/324234'; preg_match('#[^/]+$#D', $subject, $match); echo $match[0]; // 324234 Do feel free to ask if anything is unclear (like, "dude, what is that capital 'D' doing?!") or let us know if, god forbid, the pattern above isn't cutting it for you.
  18. The loop is: foreach($sets as $item): if(!in_array($item, $search)): $parts[$item] = ''; endif; endforeach; All of the values in $sets will get looped over, to put it plainly. Unless you were talking about another foreach which does not loop over $sets.
  19. Are you sure that the array $sets is not running all of its values through the foreach? You have an if statement inside the loop which might mean nothing gets done for some of the values (specifically, if they're not in the $search array).
  20. The OP never gave any hint that non-integer numbers need to be catered for. Then again, they never gave any hint that anything other than commas need to be dealt with.
  21. Or better still use $string = preg_replace('/\D/', '', $string); Which will remove anything but numbers. It's ideal for strings for numbers like 900,000,000,000 and so on [ot]Sorry. [/ot]
  22. In that case, you have lost me completely. That 'encoded code', when Base64 decoded, gives a plain recognisable string (starting with $O000O0O00=fopen($OOO0O). To reproduce: $str = 'JE8wMDBPME8wMD1mb3BlbigkT09PME8'; echo base64_decode($str); Does that really give you the "unicode" value ¨Å»pÝ×+ÑCw =žÍbGÝí`í`3ý†KûûvøÖKüÖK;ä{tÛöÛ«ÑÐå1§«�Žç™+§ ?
  23. Can you recreate this with a basic image? E.g. does the following still produce the mangled letters? <?php $im = imagecreatetruecolor(100, 50); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 49, 51, 61); imagefill($im, 0, 0, $white); imagerectangle($im, 0, 0, 99, 49, $grey); $silk = 'fonts/slkscr.ttf'; imagettftext($im, 6, 0, 25, 22, $grey, $silk, 'Managing'); imagettftext($im, 6, 0, 25, 32, $grey, $silk, '(GD '.GD_VERSION.')'); header('Content-Type: image/png'); imagepng($im); exit; Also where did you get the font file from, did you use the one from kottke.org?
  24. To read the PHP file into a string, file_get_contents makes that easy. To remove newlines, you could just use str_replace; to take care of newlines and indenting whitespace, a regular expression could be used (like /(?:\v\h*)+/ for one example).
  25. It depends on your server setup. With shared hosting, this likely won't be possible for you. With more resources (VPS, Dedicated), this might be possible for you though will be a lot of work. There are also services out there that will do what you want, generally for a small fee (or free for small numbers/restricted services).
×
×
  • 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.