-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by salathe
-
Wow a blast from the past there. It is super-duper ancient (a decade ago) and there was never a release made.
-
I guess I am not understanding your desire to stuff everything into a nested array. It is not needed and only making more work for yourself.
-
You're already doing it, in part, when calling get_object_vars(). If you haven't already, have a look over the SimpleXML Basic Usage page. $start = (string) $gauge->FifteenMinute->SampleDateStart;
-
Are you going to attach photos to all of your posts? That is a new requirement of your continued participation here.
-
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. )
-
-
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.
-
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).
-
The freelancing forum is over here: http://forums.phpfreaks.com/index.php?board=8.0
-
Visual Studio has Ctrl+K, Ctrl+D to format the document. .NET, it's the future!
-
I think congratulations are in order!
-
Can we stick to offering Deadroad sound advices, please? Thank you kindly!
-
I agree, .NET is the future! That's why I dropped PHP years ago and moved over there.
-
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?
-
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.)
-
Took over an existing project but not much has been done yet
salathe replied to alvin567's topic in Miscellaneous
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. -
Mine handled several orders of magnitude more! Shame it never went into production.
-
There's a "Preview" button for a reason.
-
how many flags can i use with html_entity_decode() ?
salathe replied to tastro's topic in PHP Coding Help
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 -
You must be doing something right, congrats.
-
Great! About time there was one with out all the crud that no-one uses.
-
Oh jing, it's a little clunky (and super, duper ugly) to work with. I wouldn't give it the thumbs up.
-
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.