Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. Use the JavaScript encodeURIComponent function.
  2. You can pass a few flags to the file function and one of those will be particularly useful here. $lines = file("basedata.txt", FILE_IGNORE_NEW_LINES); if ( ! empty($lines[3])) { echo "<li>$lines[3]</li><li>|</li>"; } Bear in mind that empty will return true for more than just a zero-length string (e.g. "0").
  3. Or, use XPath to query only for the images that you want, like: $xml = simplexml_load_file('http://ws.audioscrobbler.com/2.0/user/slaterjohn/topartists.xml?period=12month'); foreach ($xml->xpath('//artist/image[@size="medium"]') as $image) { echo $image . PHP_EOL; }
  4. You could also use array functions to do the manipulation of the randomised array. E.g. // Shuffle the player names $shuffled = $targets; shuffle($shuffled); // Create partners by rotating the randomly ordered names $partners = $shuffled; $partners[] = array_shift($partners);
  5. How about some intelligent parser to look at the post, recognise what is non-tagged code and wrap it in the appropriate tags? Hmm, sounds like too much work? Just some buttons will suffice then.
  6. Which version of Kohana are you using? Have you looked at the documentation and/or searched their forums before coming here?
  7. It hasn't been mentioned in this thread yet, but a function to do this is urlencode.
  8. salathe

    preg_split

    Or you could just split, as you were before, but with /[\t ]+/
  9. There are ~2,000 members here having an MSN address associated with their account, go wild.
  10. Or, you could just post here for help when you've got a problem which needs resolving.
  11. Use CDATA, like <itemContent><![CDATA[blah <img src="mypic"/> ... ]]></itemContent>
  12. Does this really need to be a job for regex, or would you be open to considering other methods of retrieving that information?
  13. That's probably not such a big issue, depending on precisely what you're doing. The items can still be accessed via their array offset (the "key").
  14. In your JavaScript, use if(!data.error){ or if(data.error == false){ in place of if(data.error == "false"){
  15. filter_input_array only filters GET, POST, cookie, server, env, session or request data.
  16. Wouldn't it be easier to use the results to determine how many "rows" (columns?) are needed?
  17. [ot] Sure, but it's not every day that that happens. [/ot]
  18. [ot] To be honest, this same situation occurs for me a couple of times every day. I'm happy to see that I'm not the only one who this happens to! It can be frustrating at times to have spent so much time only to not publish the post. But the frustration is only short lived and there's plenty more threads to visit.[/ot]
  19. Backtracking is a process that the regex engine will go through in an attempt to find a match, if it can. Consider the following string and regular expression: String: abcdefghi Regex: .*f When that regex is executed, the .* will match all of the characters in the string. Then it will look for an f which cannot be matched (since we're at the end of the string!). At this point the engine backtracks one character and tries allowing .* to match all but the last character in the string. Again it tries to match the letter f but fails. The engine will keep backtracking, one character at a time, until either a) an f is found or b) it has backtracked through the entire string. If that's unclear, here's the basic process that happens: [*]Match .* => abcdefghi [*]Match f => Fails (at end of string), backtrack [*]Match .* => abcdefgh [*]Match f => Fails (found i), backtrack [*]Match .* => abcdefg [*]Match f => Fails (found h), backtrack [*]Match .* => abcdef [*]Match f => Fails (found g), backtrack [*]Match .* => abcde [*]Match f => Success! abcdef
  20. With regards to the filter extension, the quoted portion of your first paragraph is just as relevant as with the regex approach. The FILTER_VALIDATE_URL filter will accept a wide variety of URLs and it's likely the application will want to accept a subset only. That said, for a first-step the filter works as advertised. Just to clarify, FILTER_VALIDATE_URL will happily accept URLs like the following (and many more): abcdefghjiklmnopqrstuvwxz://. foo://! news: file:_=~-_$.$_-~=_ .://.
  21. I'm not entirely sure why you can't arrive at this on your own (is there really such a huge leap between for and foreach?). Here's one way of doing it: foreach ($temp_property_detail['temp_property_name'] as $i => $name) { echo $temp_property_detail['temp_property_name'][$i].'<br/>'; echo $temp_property_detail['temp_property_add'][$i].'<br/>'; echo $temp_property_detail['temp_property_price'][$i].'<br/>'; echo $temp_property_detail['temp_property_size'][$i].'<br/>'; echo $temp_property_detail['temp_property_detail'][$i].'<br/>'; echo '<br/>'; }
  22. Facebook also has a whole heap of videos from their "Facebook Engineering Tech Talks": http://www.facebook.com/techtalks#/techtalks?v=app_2392950137
  23. The issue, as far as I can see, is that your regular expression is particularly inefficient (like searching for any amount of any characters then being forced to backtrack through many thousands of characters!). By default (as of PHP 5.2.0) there is a backtrack limit of 100,000. Your regex (with the space missing) needs to do more than that many backtracks so it will fail. To see that this is the problem, use preg_last_error which returns an integer corresponding to one of the PREG_*_ERROR constants.
  24. There should be no problem at all using keys with spaces. Run the following and show us the output: $fish1 = "Pseudotropheus Acei"; $fish2 = "Pseudotropheus Demasoni"; $size[$fish1] = 5; $size[$fish2] = 6; var_dump($size);
  25. salathe

    Music

    Today was a Thin Lizzy day.
×
×
  • 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.