DevelopmentNow Blog
 Saturday, September 19, 2009

We recently needed to convert a complex array structure to an object-based one in PHP. We started off with Marcel's array2object function but realized that we only wanted to "objectify" associative arrays, and leave non-associative arrays to as arrays. So here's the final function, using vhermecz's function to detect associative arrays:


function array2object($data) {
   if (!is_array($data)) return $data;
   $is_assoc = is_assoc($data);

   $object = new stdClass();

   if (count($data) == 0) return $data;

   if (is_array($data) && count($data) > 0) {
      foreach ($data as $name=>$value) {
         if ($name !== '') {
            $object->$name = array2object($value);
            $data[$name] = array2object($value);
         }
      }

   }
   if ($is_assoc)
        return $object;
   else
        return $data;
}


function is_assoc($var) {
    return is_array($var) && array_keys($var)!==range(0,sizeof($var)-1);
}

PHP
September 19, 2009    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Thursday, September 17, 2009

WikiWorldBook, the global address book, launched a social contact widget today allowing users to bring all their social networking profiles and email into a single button. Privacy controls and anti-spam features let you be found on the web on your terms, without spammers.

We've put a good amount of work into the button, and are proud to have WikiWorldBook as one of our clients. If you're looking for a better way to let friends or strangers find and contact you, take WikiWorldBook's button for a spin.

September 17, 2009    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Monday, September 07, 2009

We recntly built Infocore a mobile version of their site, complete with mobile device detection and a multi-use mobile template that is not only attractive on the latest devices, but degrades gracefully for older or smaller handhelds.

It was a fun project and we're glad that Infocore chose us for their new mobile presence on the web.

mobile | News
September 7, 2009    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]