So I got some XML and thought “well, simplexml looks like an easy way to parse the xml.” Then serialized it with json_encode and json_decode. BUT it loses the attributes on some of the nodes!!!
“Description:
————
If you json encode a simplexml object, any xml leaf nodes will lose
their attributes
The attached script has two small xml strings. One with attributes
on the leaf node, one without.
When you run the script, attribute values disappear for the second
json string”
Here’s the reply they got, that it’s not a bug!! Why does it keep some attributes, but not others, why is it not lossless??? If it DOESN’T WORK, why is it available? It’s not a bug because it wasn’t supposed to keep all the attributes, only some, randomly? Defective design doesn’t count as a bug? I don’t get it…
“[20 Oct 2008 11:10pm UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
You cannot do a lossless (loss of attributes) on an object of a certain
type such as SimpleXML.”
You can put simplexml data into session variables by casting it to string first (string), could that be one way of getting around the attribute loss by not having to use json?
Some quick notes on explaining how Euclid’s greatest common divisor algorithm works: if a=bq + r, and a=d(gq + h), where dg=b and dh=r, then d is a divisor of a, as well as of b and of r. So d|a and d|b and d|r. The recursion in the algorithm (here are the details) finds the greatest value of d satisfying d|a and d|b and d|r. I think.
This Say Yes Pt. 2 is like 3,000 times better than the track the lyrics were originally from…if you ever release Greatest Story Never Told, use Say Yes Pt. 2 instead of the original song!!!
Image from
So it can be difficult for people to do long multiplication in their heads. Luckily, the distributive property of multiplication and division can make it easier. Distributive property: a(b + c)=ab + ac. This can help, because basically, if you have two numbers multiplied by each other, you can split one or both of the numbers into smaller, more manageable digits–and you multiply the groups together. This can be easier than trying to carry digits in your head like you carry digits when doing long division on paper.
So say you have 17*15. You can split that into (10 + 7)(10 + 5). That equals, somewhat in the order you would do it doing long multiplication on paper (you can do it in any order you want)–(5 * 7) + (5 * 10) + (10 * 7) + (10 * 10). That’s 35 + 50 + 70 + 100, which is pretty easy to remember when you’re doing it in your head, as opposed to trying to carry digits etc like you do when figuring out long multiplication on paper. (I didn’t do it in the “FOIL (first-outer-inner-last)” order, I wanted to keep the order more like when you do long multiplication on paper.)
This is similar for division. For example, say you have 500/3. First, 3*goes into 5 1 times, but we have 500 not five, so 3 goes into 500 100 times, so 3*100=300, with 500-300=200. Then 3 goes into 20 6 times, but we have 200, so 3 goes into 200 60 times. So 3*60=180, and 200-180=20. We know that 3 goes into 20 6 times, 20-18=2. Then 2/3= .6, you keep getting a variation of that over and over. So add it all up: 100+60+6+.6 etc = 166.6666 and on.
Just read about this JUMP system which is supposed to make math easier for kids (and adults) to learn–I’m going to look into, that’s what I want to do too, make a system like that!
Other very important algebra for breaking down math problems:
(a + b)/c = a/c + b/c. This is really because of the distributive property: dividing by c is the same as multiplying by 1/c. So (a + b)/c is the same as (1/c)(a+b)=(1/c)a + (1/c)b=a/c + b/c.
So you may be in algebra or algebra II, and be introduced to negative exponents. Here’s a good way of understanding how they work. When you have an exponent, like b^x, where b is the base, you can split b into b*1, since all numbers are itself times one, this may make it easier to understand. Then b^x means you have 1 times a series of multiplications of b’s x long. So that’s why b^x, where x is zero, is 1: you have a 1with no b’s being multiplied; if x is 1 you have 1 times one b, which equals b; b^2=1*b*b, and so on. Now, if x is negative, that means you have 1 being divided by a series of a multiplication of b’s x long. So b^-1 equals 1/b, b^-2 equals 1/(b^2), and so on.
The movie the Matrix has many homages in it to the movie Commando.
Check out this scene at 2:55 in this video of the mall fight in Commando where all the cops pile on Arnold and he throws them off–exactly like when all of those Agents pile on Neo and he throws them off. Here’s the Matrix Reloaded fight, the part is at 4:50-5:03.
Then there’s the scene where Arnold goes “shopping” for weapons…
at 1:32 in this video he discovers the secret room in the store filled with racks of like unlimited machine guns and other weapons…it’s EXACTLY like in the Matrix where the good guys go in that virtual room with like racks of like unlimited machine guns and other weapons
Here’s the Matrix homage to the Commando “shopping” scene:
Then of course, Arnold’s name is Colonel Matrix in the movie…yay!
I looked up this album after hip hop producer Just Blaze used the image of the cover as his Twitter icon. What…is…going…on…in…this…video??? Some sort of weird alien multi-gendered Grand Theft Auto hip hop animation…with bear roars…???