Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. Are you going to attach photos to all of your posts? That is a new requirement of your continued participation here.
  2. Note: the following is mostly tongue-in-cheek comments and should not be taken seriously, or quoted against me in the future. Only relatively recently did E_ALL actually encompass everything. For PHP 5 < 5.4.0 it wasn't all since E_STRICT was not included. Also, E_ALL has never been -1. Yes, we know. He still has one point. I guess the following counts as a design philosophy. Expression-level, which PHP uses, is even MOAR powerful. By convention, core functions don't throw exceptions. OOP constructs should throw exceptions, but json_decode() isn't one of those. The correct thing (currently available) to be doing for functions that may give the same return value for success and failed states is indeed to check the associated error function, that is what they're there for. Say what? "One of the key-points of PHP 5 OOP that is often mentioned is that "objects are passed by references by default". This is not completely true." - read the whole article. Anyone else feel like scrolling up to where he complains about function names being case-insensitive? No? Coding standards; believe it or not, even PHP has them. The article had this right when saying accessible (or in PHP parlance, visible), rather than your public. The properties iterated over are the visible ones. Also,ArrayAccess bears no relation on what happens with foreach(). As for function names, inconsistencies, and all that jazz; some food for thought. (I'm sure he's fine with me quoting him completely out of context. )
  3. I guess you missed my entire point, there is no need to "convert" SimpleXMLElement objects into arrays (with get_object_vars(), casting, etc.) in order to use them. Learning how to work with SimpleXML will be much more beneficial than always working against it. It is really only a baby step of difference between using nested arrays and using SimpleXMLElement objects.
  4. There is absolutely no need to create that array of "first children" names, only to use it to get the readings that you want. There is also no need to loop over the readings once to get them into an array, then loop over them again in array form to do whatever you want with them. It's all looking like doing unnecessary work. $data_url = 'http://www.amecim.com/metronashvillewater/metronashvilleraingaugeservice.asmx/getAllGaugesAllIntervals'; $package = new SimpleXMLElement($data_url, NULL, TRUE); foreach($package->children() as $gauge) { $sample = $gauge->TwentyfourHour; // Access the data using the tag name // e.g. $sample->GaugeName } If you haven't already, have a good (re-)read through the SimpleXML Basic Usage manual page which has lots of examples and instructions. The key take-home point, I think, is that you need to remember how the SimpleXML object structure relates to the XML structure. For example, the first SimpleXMLElement object ($package) contains the <clsRainGaugeIntervalSetPackage> element. Then we loop over its children(), which are the <BntCrk>, <Brentwood>, <GibsonCrk> ... elements. For each of those children, we grab the <TwentyfourHour> element and then you are left to get the child elements for whichever bits of information you want (see the comment).
  5. The freelancing forum is over here: http://forums.phpfreaks.com/index.php?board=8.0
  6. Visual Studio has Ctrl+K, Ctrl+D to format the document. .NET, it's the future!
  7. I think congratulations are in order!
  8. Can we stick to offering Deadroad sound advices, please? Thank you kindly!
  9. I agree, .NET is the future! That's why I dropped PHP years ago and moved over there.
  10. The preg_match() page already links through to the "PCRE Patterns" chapter, from there it should not have proved tricky (though clearly did) to find what you needed. Two of the four further links on that ("PCRE Patterns") page mention delimiters, and take you right to the detailed information about them. I can only advise that people read through the PCRE Patterns chapter before trying to use the associated functions. A link could be added from the preg_match() page directly to the "Delimiters" page, but where do we draw the line? Should the function page also link to the Performance, Repetition, Character classes, ... pages?
  11. Frost was a naughty boy, he has been asked to not to cross the nice-behaviour line as often in the future. End. Of. Thread. (Before we make it about Alexi.)
  12. Don't air your work frustrations here, especially when saying that you simply cannot do your job. Go talk to your boss, colleague(s), or the water cooler.
  13. Mine handled several orders of magnitude more! Shame it never went into production.
  14. There's a "Preview" button for a reason.
  15. Yes, when used incorrectly, flags can overwrite one another. For example, ENT_QUOTES|ENT_NOQUOTES is identical to ENT_QUOTES. The document type flags are not related to the input document, but the type of entity or conversion used for the returned string. They're there to ensure that the returned value from the function is suitable for output in that document type. You should not be using all available flags at the same time. Use at most one flag from each group that has multiple choices. Quote handling (choose one) ENT_COMPAT ENT_QUOTES ENT_NOQUOTES Document type (choose one) ENT_HTML401 ENT_XML1 ENT_XHTML ENT_HTML5 Mix and match any/all of these ENT_IGNORE (don't use this) ENT_SUBSTITUTE ENT_DISALLOWED
  16. You must be doing something right, congrats.
  17. Great! About time there was one with out all the crud that no-one uses.
  18. Oh jing, it's a little clunky (and super, duper ugly) to work with. I wouldn't give it the thumbs up.
  19. Easy, using array_keys. array_keys($array, max($array)) That's assuming you want all of the keys for the single highest value rather than the keys for the two highest items if sorted.
  20. It's often not the OP's fault if their ISP allows access from anywhere on the intertubes, they really should at least have access hostmasks set up on a per MySQL user basis. That said, if anyone does see/make this mistake and wants to alert the moderators, we're happy to edit the post if we haven't seen to it already.
  21. Just for clarification, here is a note from the parse_ini_file() manual page:
  22. You will likely want to modify your do_post_request() function to not include the headers, unless there is any particular reason why you need them.
  23. You could use the glob() function (docs) to get a list of directories. The idea being to build up your array in a loop like: $directories = glob($baseDir . '/*', GLOB_ONLYDIR); foreach ($directories as $directory_path) { $directory_name = basename($directory_path); $config['ResourceType'][] = array( 'name' => $directory_name, 'url' => $baseUrl . $directory_name, // and the rest of your array values ); }
×
×
  • 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.