Jump to content

DarkWater

Members
  • Posts

    6,173
  • Joined

  • Last visited

    Never

Everything posted by DarkWater

  1. if (!in_array(strtolower($_GET['sstring']), array_map('strtolower', $names))) { That SHOULD work. And should the GET variable be 'sstring', or did you mean 'string'?
  2. mysql_fetch_array() stores the array with both numeric indexes and string indexes. _assoc only performs the latter, which is what you want for extract().
  3. Use extract() on the array returned from mysql_fetch_assoc(). Be careful, as it WILL overwrite variables that already exist with the same name.
  4. The 347 is from readfile(). readfile() returns an integer representing the number of bytes read in. I don't understand the point of s() though...
  5. @omarh: Just about everything in that code that could go wrong DID go wrong. You used short tags, you didn't bother indenting, you didn't use the negative length option of substr(), and you used ereg_replace(). It's so much better with a nice, simple regex.
  6. <?php preg_match('/(\d+)<beforethis>/i', $html, $match); echo $match[1]; ?>
  7. I wasn't entirely sure if someone decided to make a MAMP package, but I guess they did. Nice to know. I haven't checked it out yet, but it should probably work fine. Remember that you NEED to go through localhost in order to actually have anything processed by the server (and PHP). You can't just double click the file and open it in Safari or Firefox (or whatever you are using).
  8. Just a matter of installing the web server and configuring it to use PHP. You shouldn't really have too much trouble with it. Google 'mac apache php' and you'll probably get some tutorials.
  9. Absolutely. Download Apache, PHP, and MySQL (if necessary). If you use Windows, go and Google 'WAMP' and you should be able to find a site that has all three available for download in a little package that installs everything for you.
  10. <?php function factorial($num) { if ($num == 1) { return 1; } return $num * factorial($num - 1); } function permutations($array, $num) { return factorial(count($array)) / (factorial(count($array) - $num)); } $group=array(49,21,32,31,45,22,34,23,43,20,24,25); echo permutations($group, 6); ?> If my math skills aren't failing me, that should work.
  11. Just use a session? You should never pass a string through the URL only to display it right on the next page....that's kind of dumb.
  12. Or, you could download Firefox and use AdBlock.
  13. http://www.phpfreaks.com/tutorial/regular-expressions-part1---basic-syntax/page5 Add a ? after the + next to the dot. .+?
  14. @Mikedean: Not really. Inheritance should not be used in this case. Not at all. Inheritance is really one of the most abused things in OOP. =P @Thread starter: If your User class is directly using a DB instance, you're doing it wrong. Honestly. Go read up on design patterns and OOP principles. Before you go recoding procedural code directly into useless OOP functions, learn how and why OOP should be used. In reality, a user (remember, OOP was made to model real world situations) would not go contact the database to see if they existed. A User has nothing to do with a Database, so they should not be coupled like that.
  15. <?php $string = " text text text house cars [ball] test boat [one two three] ball toy text text a lot of text [nice ball] other text"; preg_match_all('/\[([^\]]+)\]/', $string, $matches); print_r($matches); ?> $matches[1] will be a multidimensional array containing the strings you want.
  16. array_union() is not a PHP function. Perhaps you mean array_intersect()?
  17. I found 2975 errors when I just checked. New record again!
  18. Even if you use php includes and the full potential of css, it is extremely difficult to change the design after the website is completed. That's why the invented templating systems.
  19. Eh....the layout is very crowded and I don't like the colors. It sort of gave me a headache. I really think you should completely redesign the layout and make it MUCH cleaner. By the way, I don't mean to be offensive; I'm just offering comments.
  20. Wait. Help me understand something here. Why in the world would you take extra effort to go to the "Core PHP Hacking" forum, realize that the posts in the section have NOTHING to do with your question, and then post anyway rather than go to the "PHP Help" section?
  21. Seems like the quotation marks got taken off. Let's see if it does it again: <?php $string = " <a href='blah' id=1234.2>[FLAG] something</a> <a href='blah' id=829.1>somethingelse</a> <a href='blah' id=634.5>somerandomcharlength</a> "; preg_match_all('~<a.*?id=([0-9.]+)[^>]*?>(?!\[FLAG\]).*?</a>~', $string, $matches); print_r($matches); ?> EDIT: That's so odd. It seems to be stripping the opening quotation mark, but it's there if you try to quote my post. =/
  22. <?php $string = " <a href='blah' id=1234.2>[FLAG] something</a> <a href='blah' id=829.1>somethingelse</a> <a href='blah' id=634.5>somerandomcharlength</a> "; preg_match_all('~<a.*?id=([0-9.]+)[^>]*?>(?!\[FLAG\]).*?</a>~', $string, $matches); print_r($matches); ?> You should be using negative lookaheads for this. This regex works as expected.
  23. Can I see a print_r() on $page['towns']?
  24. list($fname, $lname) = explode(' ', trim($Name)); =/ Why, in your code, did you put: , true After your variable assignment?
×
×
  • 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.