Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. Get an array of the <case> elements by using XPath like $cases = $xml->xpath('title/case'); or manually create an array of <case> elements $cases = array(); foreach ($xml->title->case as $case) { $cases[] = $case; } then shuffle to your heart's content.
  2. ... will usually work fine... For reference to some differences, see http://php.net/reference.pcre.pattern.posix
  3. Use the m pattern modifier with your existing regex. P.S. Life would be easier if you also used the file_get/put_contents functions. http://php.net/reference.pcre.pattern.modifiers http://php.net/file_get_contents http://php.net/file_put_contents
  4. Show us the XML ($tmpgs).
  5. I would. I avoid a number of forums here because separating the wheat from the chaff is tiresome. (But maybe that's a fault on my part, not PHPFreaks'.) bigjoe11a, I had a quick scan over your posts and I wouldn't really qualify them as "advanced PHP", more your every day "I need halp" questions.
  6. kirill578, read through the PHP manual section on regex patterns[1] a few times (you likely won't absorb everything in one sitting!). And keep going back to it for reference. [1] http://php.net/reference.pcre.pattern.syntax
  7. json_encode()
  8. Use glob() or scandir() which sort alphabetically. If their sorting does not suit, use one of the numerous array sorting functions or even go crazy and use your own sorting algoritm. If you need help, after having a go, then show us where you're stuck at and we can assist.
  9. Is $view_rows really an array of arrays? Check that it is one (e.g. with var_dump($view_rows)) directly above the line with the problem and tell us what it says.
  10. Approximately 0.0953674316 megabytes, just in case you were still unsure.
  11. SMF provides feeds for individual forums, there's just a little work to do to figure out the correct feed URL (since the site uses "friendly" URLs). For example, an RSS 2.0 feed of the 20 latest posts in the regex forum is located at http://www.phpfreaks.com/forums/.xml/?type=rss2&limit=20&boards=43
  12. See Example #6 on http://php.net/simplexml.examples-basic
  13. Me. Please, don't.
  14. Me. Of course.
  15. Your main problem is using $n_data->channel->item where you want to be using $n_data->item. When you construct a new SimpleXMLElement instance like you're doing, the document's root node (<channel>) is what that instance represents. You'll also probably want to cast the values to strings when you put them into the $arr2 array.
  16. There are three problems, one is stopping your script from being useful and another is just a choice. The third is a general tip. Firstly, the correct property to use is $node->textContent. Next, you can (and probably should) use $xml->load("link.xml"); and finally please learn to enable, display and understand error messages: use error_reporting(-1) while you're writing code and take note of the helpful messages.
  17. Very comfortable. sjgoodjob, did you mean that the study guide alone would not have been enough for you to pass the PHP 5 certification?
  18. What do you mean "doesn't work"? Are any errors displayed, or logged? What version of PHP are you using? Does date_diff() work for you in other scripts? Finally, and importantly, have you read the manual page for date_diff()?
  19. How are you calling file_get_contents()? The function will not evaluate PHP code, it simply fetches the content of the file (or output of an URL) and nothing else.
  20. Oh, it has got tables! Then I'm sorry you'll have to start all over again! Joking aside, your $pattern only looks for <td>...</td> so since the page uses tables, you should be OK (fingers crossed).
  21. Great to see that you're happy. If you could press the green "mark solved" button down below these posts, others can see that the thread has been solved.
  22. If the "target URL" has the HTML structure and content that $pattern looks for, then yes. Otherwise, no.
  23. What exactly did you try? Yes, it does fix the problems I've mentioned unless either a) there's something else you're not telling us, or b) you didn't do the correct replacement.
×
×
  • 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.