Skip to content

Instantly share code, notes, and snippets.

@peterjaap
Created March 5, 2014 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterjaap/9367574 to your computer and use it in GitHub Desktop.
Save peterjaap/9367574 to your computer and use it in GitHub Desktop.
This function creates a multi-dimensional Varien_Object by inputting a multi-dimensional array
<?php
public function getArrayToObjectResults($array) {
$obj = new Varien_Object();
foreach($array as $k => $v) {
if(strlen($k)) {
if(is_array($v)) {
$obj->{$k} = $this->getArrayToObjectResults($v);
} elseif ($k !== '') {
$obj->{$k} = $v;
}
}
}
return $obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment