Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. Look into using Math.random (and basic arithmetic operators as well as likely Math.floor) for generating a random number and the DOM for changing attributes (particularly the setAttribute method on DOM Elements). Hopefully that's enough keywords to search on.
  2. Oh really? There goes my learning C to contribute to the source.
  3. Hi Fog37, welcome to PHPFreaks.
  4. That could probably be written a lot simpler using a RecursiveDirectoryIterator, or are you happy with what's there?
  5. Insted of escape, use encodeURIComponent. You'll also want to do the same for param.
  6. The symbol is awful for debugging! Please don't just use it because it's a convenient hack, check that what you're providing to the function is proper before using it as an argument.
  7. Hehe, oops my mistake.
  8. With regards to the email filter presented, all that it does is run the value through a regular expression. Nothing magical nor complicated.
  9. Hardly surprising but my favourite is: http://xkcd.com/208/
  10. Are you running that code from the same IP address as the web service (125.236.209.214)?
  11. How variant is your IP address; how often are there other log entries containing an IP that you have used but is not you?
  12. Maybe I'm missing the point (it happens occasionally) but couldn't you just pack whatever you want into binary?
  13. How are you creating the JSON values because they're malformed: for the last one you posted there was an extra ] and some missing ]} chars. A helpful friend here is http://www.jsonlint.com
  14. Just to reiterate what teamatomic said, do you have the APD PECL package installed because it doesn't look like it is. The function is part of an extension to PHP (in the PECL repository, which is why it is documented in the manual) and not the "core" that everyone has.
  15. [ot]Surely words like "a" and "I" also start and end with the same letter, right? [/ot]
  16. Shouldn't your results also have the range 230-239 or do you wish only those that end in the inputted number?
  17. Almost random, except for the extraneous space characters attached to the 'malfunctioning' values. Get rid of that whitespace and I'd hazard a guess that the problem will go away. [ot]Why are you splitting on 1234567890 rather than something more usual like... a line break?[/ot]
  18. There is a PECL extension (it used to be in the PHP core) for monitoring files and directories but from the sounds of things your approach hardly seems ideal. Why can't you pipe the email directly to the PHP script which saves the message to the database?
  19. The second XPath query (within the loop) relates to the root of the document even though you're trying to use a context node. To make the path relative, start it with a dot (.//div[).
  20. We use CentOS for our web boxes and Ubuntu for the desktops. Not out of any particularly great affection for either but they get the job done.
  21. If you mean the ?: then that is a ternary operator.
  22. It's also perfectly possible to take the XPath idea and use it with SimpleXML like: $xml = <<<XML <comments> <comment lang="fr_FR"><![CDATA[lalalalalalalalalalallala]]></comment> <comment lang="en_GB"><![CDATA[hello english descriptions]]></comment> <comment lang="de_DE"><![CDATA[yayayayayayay]]></comment> <comment lang="it_iT"><![CDATA[]]></comment> <comment lang="es_ES"><![CDATA[]]></comment> <comment lang="ru_RU"><![CDATA[]]></comment> <comment lang="no_NO"><![CDATA[]]></comment> </comments> XML; $sxml = simplexml_load_string($xml); $lang = 'en_GB'; $nodes = $sxml->xpath("/comments/comment[@lang='$lang']"); echo "Comment for lang '$lang' is: $nodes[0]";
  23. There are lots of ways of doing this: you could use a regular expression (preg_match), string functions (strpos, strstr, strtok, etc.), or you could even go crazy with sscanf like $filename = 'logFile (month.year) [number of hits in that month].txt'; sscanf($filename, '%*[^[][%[^]]', $hits); var_dump($hits);
  24. You could also use array_chunk to split the list of player IDs into pairs. Like: $list = '3847, 3795, 80880, 3453, 56456, 27431, 82903, 17879, 789222, 9839832, 90823432, 234234, 1232323'; // Split into array of IDs $players = explode(', ', $list); // Shuffle the array shuffle($players); // Chunk into pairs $pairs = array_chunk($players, 2); foreach ($pairs as $pair) { // If not pair (i.e. list had uneven number of IDs) skip if ( ! isset($pair[1])) { continue; } printf("Player Id: %d Vs Player Id: %d\n", $pair[0], $pair[1]); }
  25. /[.?]\s+/ That will do what you want as well as a few other things like split on a ? followed by a newline and \s includes other whitespace like tab, formfeed and carriage return characters.
×
×
  • 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.