Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. One way would be to use sscanf like: $row = '2010/06/28 22:54:59 administrator 13 -1'; $reg = sscanf($row, '%d/%d/%d %d:%d:%d %s %d %d'); And another would be to use fgetcsv and specify tab as the delimiter character. (The function is named CSV for comma-separated values, but is equally happy with tab-separated values like your file).
  2. This would be much easier without regular expressions, there are tools in PHP dedicated to parsing this kind of (tab-separated value) file, or more useful (and simple) string-parsing functions to do the job manually. Do you ultimately want the array to be like that you posted (in the first post) or would you like the date and time values kept together?
  3. Even if folks did pass the package on to each other, you'd still have to "handle" the postage... or would you expect them to donate and pay for posting to some other person not of their choosing?
  4. No. The idea itself also sounds impractical. What if you have people sending you (or, the charity) money more quickly than "package Z" can be posted, received and sent on again?
  5. Here's an alternative idea: $pool = range(1, 45); $questions = array(5, 9, 10, 12, 33, 39); // Get a list of questions from the pool that have not already been asked $available = array_diff($pool, $questions); // Get five random questions from the list of available ones $random = array_rand(array_flip($available), 5); print_r($random);
  6. Just to make it clear, this code will remove more than just <br> tags from the start of a string. Given breakfast the result would be eakfast, given <b>robber</b> would result in obbe.
  7. salathe

    Preg Match

    The changes that I mentioned are for your script, not the remote server.
  8. salathe

    Preg Match

    You could set the user_agent INI option, or provide a stream context for SimpleXML to use. The first just dictates the default user agent to send along, the second allows far more fine-grained control of the request.
  9. Awesome, now are you going to introduce yourself?
  10. salathe

    Preg Match

    I don't have a Shoutcast server to try this on but the following should, theoretically, also work*. Or at least show you an alternative approach should you want to use it. echo simplexml_load_file("http://68.168.98.191:13511/admin.cgi?pass=&mode=viewxml")->SONGTITLE; * Assuming of course that the SimpleXML extension is enabled and it can talk to that URL.
  11. You can't write to the interwebs.
  12. Your description of the ™ not being replaced properly makes no sense, given the regex that you're using... it will never replace just an ampersand. As for having entities in the XML document, they would be fine if you used a CDATA block like <blah><![CDATA[This is my ™ text isn't it ©?!]]></blah>
  13. salathe

    Preg Match

    Your regular expression is case-sensitive meaning that the lowercase letters will not match the uppercase letters which are present in the XML. Either change the regex to have uppercase SONGTITLE or use the case-insensitive pattern modifier (/.../si) to match your pattern case-insensitively. Also, why are you using antiquated methods of a) retrieving the XML and b) accessing the SONGTITLE?
  14. The problem with the regex is that the * quantifier is being "greedy" and gobbling up much more than you want. You have a few options: make it ungreedy (.*?) or change the item being quantified ([^;]*). Also, why do you want to convert the entities? Can you give an example of the ATOM feed that you're working with, I have a feeling this really should be a non-issue.
  15. No need for the if/else if you're using abs.
  16. $diff = abs($time1 - $time2); Do you want the time difference in seconds, or some other format?
  17. Do you know what you're wanting to protect against?
  18. So, in all fairness, who do we complain to when we have a problem with an administrator? I'm not sure you guys are being helpful at all.
  19. I haven't had any complaints yet. I guess there really aren't any!
  20. Feel free to send any and all complaints about thorpe to my inbox.
  21. date_default_timezone_set
  22. Have you had a look around the forums here? There are loads of threads asking about ignoring stuff within a tag.
  23. Your regular expression should be more specific about what (where) it will match so that if the URL appears within an anchor tag, the match is not successful. This sub-forum has lots of threads trying to do precisely that.
  24. For what it's worth, the bbcodes available here are listed in the help section (there's a link at the top of every page). Here's a direct link http://www.phpfreaks.com/forums/index.php?action=help;area=bbcode
  25. TheKiller... some text
×
×
  • 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.