Archive for December, 2009
Revised convertObjectToArray function for PHP
Posted by visual77 in programming on December 10, 2009
Back in July, I wrote an article about converting an object to array in PHP and mentioned the difficulties I was having with filtering private and protected keys to remove undesirable characters. I found a solution not long after, but never got around to writing a follow up. Here is my current function library to convert an object to an array, recursively, while maintaing nice keys.
< ?php
function convertObjectToArray(&$element) {
// the recursive call can't operate through objects, so they
// must be handled specially
if(is_object($element)) {
// typecast the object to an array, and clean up private and
// protected keys
$element = convertObjectToArray_keyCleanup((array)$element);
// begin the recursion again to go through this object-turned-array
// this is not strictly necesary, as removing it will cause the
// recursion to happen in convertToXml, but putting it here makes it
// more readable and ever so slightly faster.
array_walk_recursive(
$element,
'convertObjectToArray'
);
}
return $element;
}
function convertObjectToArray_keyCleanup($array) {
// find every invalid key (private and protected member properties)
foreach(array_filter(array_keys($array), 'convertObjectToArray_invalidKey')
as $invalidKey) {
// change the key name by copy / delete / create
$data = $array[$invalidKey];
unset($array[$invalidKey]);
// find out the correct key name by getting the last chunk that
// is only ascii 32 - 126, the standard set of printable characters
// User�Types => Types
$key = preg_replace(
'/^.*[^\x20-\x7E]([\x20-\x7E]*)$/',
'\\1',
$invalidKey
);
$array[$key] = $data;
}
return $array;
}
function convertObjectToArray_invalidKey($key) {
// a key is invalid if it has any characters that are outside
// of the ascii range 32 - 126, which is the standard set of printable
// characters
return preg_match('/[^\x20-\x7E]/', $key);
}
?>
World of Warcraft Patch 3.3 – Dungeon Finder
The new World of Warcraft Dungeon Finder system was released with patch 3.3 yesterday, and it is a much needed improvement on the previous Looking For Group system. Unlike the old system, DF does not require constant attention by the party leader to seek out that elusive tank or healer to fill out the group before going to the instance. Instead, each person places himself in the queue for a particular role. Once DF has matched up a full, balanced group, you are prompted to enter the dungeon in a similar fashion to the Battlegrounds queue.
Also similar to the Battlegrounds queue, the DF system works across the entire battlegroup. The battlegroup is a cluster of 10-20 servers, vastly increasing the available player pool to find group mates. This makes matchups happen more quickly and the automatic matchmaking system insures you have a balanced group. Once you are in the instance, it operates just like the old instances, except for the reward system for doing random dungeons.
The reward system grants bonus money, experience and special Emblems as an incentive to use the random dungeon system to find groups. As a level 74, my first run of the day got me 14g, 33,100 xp (about 1.5 times a normal quest) and 2 Emblems of Triumph. Those emblems are currency for some exceptionally good equipment once I hit level 80.
This new system, as amazing as it is, does have its flaws. I tried three DF groups last night with only 1 ending in a successful dungeon run.
My first run was a run through Drak’Thalon Keep where I ran as a healer on my 74 Restoration Shaman. The group ran through DK just fine and upon completion, I was teleported back to Dalaran, which was my location prior to entering the dungeon.
My second attempt was trying to enter DF as a group with a 73 Rogue. Even that 1 level disparity was enough to block us from entering most of the dungeons I was allowed to enter on the previous run. Drak’Thalon Keep, Violet Hold, Azjol-Nerub and others were off limits due to the 73 in the group. I can attest, however, that this particular 73 can easily hold his own above his level. On a particularly odd note, even Utgarde Keep was marked off limits with a message indicating it was due to him. Not only has he already run UK before, but if either of us would block us from UK, it should’ve been me at 74. In the end, he left before we were able to find a dungeon.
My third attempt was another solo attempt that got an Azjol-Nerub run within 5 minutes, but locked up shortly after. At the AN loading screen, the game stalled until I was kicked back to Dalaran. However, I was still in my party and upon leaving the party I was given the Deserter debuff. This debuff is a disincentive to leave groups before the run is over and prevents you from joining DF for 15 minutes. I am all for this system, except when I am given it after being kicked from the dungeon.
Once these kinks are worked out, this system will improve the game in many ways. I know I will be running a lot more instances through this system than I ever would have with the older system. It makes it as easy as Battlegrounds to get in queue and then go about your normal business waiting on the group to form. I think Blizzard has done some great work here that keeps World of Warcraft fresh and keeps advancing the game.
Now, where is my aesthetics gear?
Google Voice transcription is chock full of fail
I got into Google Voice on Friday for use with my Motorola Droid (fantastic phone, fyi) and used it for the first time today. I had one of my coworkers call my phone (from his Droid, nonetheless, which he loves) and leave a voicemail.
He said “…available. Steve, this is Phil, my code’s gone awry, help. Call me back. Bye.” and the transcription says “So what the this info. Marco dot. R. R. L. Call me back alright.”
The interface is nice, though. It shows all of my voicemail and lets me listen to them in any order. The transcription has clickable links, too, so you can click a certain spot and it will begin playing at that spot. It would be better if the transcription wasn’t awful, though.
This week on twitter – 2009-12-06
- Getting gas with no jacket… so cold #
- Transferring the stout to secondary. I've never seen beer this black. #
- This is my first day without drugs since Saturday. Hopefully the cold has gone away enough so that I won't have to take anymore. #
- I probably shouldn't be at work today. My illness is at its peak, I'm dizzy and now my head is tingling. #
Powered by Twitter Tools