Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. You'll have to be careful with that approach. For instance, you risk censoring "grass" to "gr***" when you censor "ass". You can "fix" that like this: $badwords = array('bad1', 'bad2', 'bad3', 'ass'); $text = 'This is a test. Ass. Grass. bad1.'; function filterBadwords($text, array $badwords, $replaceChar = '*') { return preg_replace_callback( array_map(function($w) { return '/\b' . preg_quote($w, '/') . '\b/i'; }, $badwords), function($match) use ($replaceChar) { return str_repeat($replaceChar, strlen($match[0])); }, $text ); } echo filterBadwords($text, $badwords); Output is: This is a test. ***. Grass. ****.
  2. You can split a string by a delimiter using explode.
  3. You might also want to lookup SQL injections and XSS so you can close those security holes. They're mentioned in this tutorial: http://www.phpfreaks.com/tutorial/php-security
  4. The way that PHP converts strings to integers is by reading all characters until the first non-digit character is found. This means that (int)"0xFF" becomes 0 and not 255. See: http://dk.php.net/manual/en/language.types.string.php#language.types.string.conversion
  5. Use the curl_multi_*() functions to download in parallel.
  6. Doesn't it allow you to pass parameters to the programs so you can do something like "C:\php5\php.exe C:\path\to\script.php"?
  7. You could start with spending your time on research instead of spending it on bumping this topic.
  8. Assuming that username is primary key (or just any key) in the other table, that would be perfectly fine.
  9. Did you even try running the code to see what happens?
  10. Then that is what is in the XML document...
  11. XML is plaintext. You can open it in any editor.
  12. What exactly makes you think you're entitled to multiple voices? Basically they should be sued because you like Mike's voice better than Anna's? Please stop trolling.
  13. Didn't you already receive a response? Is there anything else you need help with?
  14. If you give me a deterministic way of determining that with only that information available, I'll write a rewrite rule for you.
  15. I absolutely lost it. LOL, the letter u is miles away from the letter a on a keyboard. What where you thinking? If he is using Dvorak, both of them are at the home row, and he is likely to rest his left hand on both of those keys
  16. Use move_uploaded_file; it's only restricted on the destination.
  17. PHP is written in C. You can read the source code here: http://svn.php.net/php/php-src/trunk/
  18. That's not what register_long_arrays means. If you set this to on, then the $HTTP_*_VARS superglobal arrays will be populated. Those are deprecated, by the way.
  19. For the sake of readability, I'd just use a regex in this case: if (!preg_match('#^\+\d+$#', $number)) { // it's invalid } Alternately: if ($number[0] != '+' || !ctype_digit(substr($number, 1))) { // it's invalid }
  20. So 1.234e56 is a valid phone number in your eyes?
  21. It is possible doing something like it, assuming your web server is not setup to always buffer the output and that your browser doesn't try to load the entire thing first. <?php header('Content-type: text/plain'); $i = 1; while ($i <= 100) { echo $i++ . PHP_EOL; flush(); ob_flush(); usleep(500000); } Live example: http://files.degeberg.com/flush.php This works for me in Firefox 3.6.3, but not in Chrome 6.0.422.0 dev.
×
×
  • 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.