Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
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. ****.
-
You can split a string by a delimiter using explode.
-
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
-
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
-
Is it Possible to Make this "Get Image" Code Any Faster?
Daniel0 replied to jebego's topic in PHP Coding Help
Use the curl_multi_*() functions to download in parallel. -
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"?
-
You could start with spending your time on research instead of spending it on bumping this topic.
-
Assuming that username is primary key (or just any key) in the other table, that would be perfectly fine.
-
Did you even try running the code to see what happens?
-
Then that is what is in the XML document...
-
XML is plaintext. You can open it in any editor.
-
protecting against SQL Injection without adding slashes?
Daniel0 replied to crocop1's topic in PHP Coding Help
Turn off magic quotes. -
My computer is a girl! How can I change the TTS voice in Windows 7?
Daniel0 replied to tibberous's topic in Miscellaneous
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. -
learnt OOP basics but just cannot understand a framework
Daniel0 replied to langenf's topic in Miscellaneous
Are you sure? -
Didn't you already receive a response? Is there anything else you need help with?
-
If you give me a deterministic way of determining that with only that information available, I'll write a rewrite rule for you.
-
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
-
Use move_uploaded_file; it's only restricted on the destination.
-
What language are php functions originally written in?
Daniel0 replied to shadiadiph's topic in Miscellaneous
PHP is written in C. You can read the source code here: http://svn.php.net/php/php-src/trunk/ -
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.
-
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 }
-
So 1.234e56 is a valid phone number in your eyes?
-
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.
-
thoughts about the ip addresses and coming shortages
Daniel0 replied to basireid's topic in Miscellaneous
Yes. Fixed now