array2object

Convert an associative array to an anonymous object.

7 calls to array2object()

File

includes/common.inc, line 423
Common functions that many Drupal modules will need to reference.

Code

function array2object($array) {
  if (is_array($array)) {
    $object = new StdClass();
    foreach ($array as $key => $value) {
      $object->$key = $value;
    }
  }
  else {
    $object = $array;
  }

  return $object;
}
Login or register to post comments