Blog about inconsequential things

PHP casting an object to an array

This just cost me a day. I had a JSON structure that I wanted in an array.
{
   "10": {
      "foo": "bar"
   },
   "20": {
      "baz": "fup"
  }
}
So the easiest way to do this (I thought) would be:
$content = (array)json_decode($some_json)
but I could not access any array element event though I could clearly see that the key existed
print_r($content[10]);
PHP Notice:  Undefined offset: ...
After slowly going insane I found a stackoverflow post that pointed to this
If an object is converted to an array, the result is an array whose elements are the object's properties. The keys are the member variable names, with a few notable exceptions: integer properties are unaccessible; private variables have the class name prepended to the variable name; protected variables have a '*' prepended to the variable name. These prepended values have null bytes on either side. This can result in some unexpected behaviour:

This is fucking insane. Who comes up with this shit!?

Your rating: None Average: 5 (2 votes)

Upgrade 2006 MacPro1,1 to Mavericks

After Apple dropped support for the first MacPro models I got seriously disillusioned with the company. After all I had plunked down a bundle back in 2006 to purchase an upgradable desktop computer.

Your rating: None Average: 5 (2 votes)

Guilty as charged

Your rating: None Average: 4.7 (3 votes)

RESETTING THE PASSWORD

"Sorry, your password has been in use for 30 days and has expired - you must register a new one."
Your rating: None Average: 5 (1 vote)

Fallacies of Distributed Computing

This is something I have to do with on a daily basis. The list sounds silly, but is spot on:

  1. The network is reliable.
  2. Latency is zero.
  3. Bandwidth is infinite.
  4. The network is secure.
  5. Topology doesn't change.
  6. There is one administrator.
  7. Transport cost is zero.
  8. The network is homogeneous.

usually we are affected by all of them

Syndicate content