Skip to content

Commit

Permalink
Fixed an error with multidimensional structures being passed through …
Browse files Browse the repository at this point in the history
…to_array().
  • Loading branch information
Phil Sturgeon committed Mar 26, 2011
1 parent 1190734 commit 0a14e87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions application/controllers/api/example.php
Expand Up @@ -80,4 +80,10 @@ function users_get()
$this->response(array('error' => 'Couldn\'t find any users!'), 404);
}
}


public function send_post()
{
var_dump($this->request->body);
}
}
11 changes: 6 additions & 5 deletions application/libraries/Format.php
Expand Up @@ -57,14 +57,15 @@ public function __construct($data = null, $from_type = null)

public function to_array($data = null)
{
if ($data === null)
// If not just null, but nopthing is provided
if ($data === null and ! func_num_args())
{
$data = $this->_data;
}

$array = array();

foreach ((array) $this->_data as $key => $value)
foreach ((array) $data as $key => $value)
{
if (is_object($value) or is_array($value))
{
Expand All @@ -81,9 +82,9 @@ public function to_array($data = null)
}

// Format XML for output
public function to_xml($data = null, $structure = NULL, $basenode = 'xml')
public function to_xml($data = null, $structure = null, $basenode = 'xml')
{
if ($data == null)
if ($data === null and ! func_num_args())
{
$data = $this->_data;
}
Expand All @@ -94,7 +95,7 @@ public function to_xml($data = null, $structure = NULL, $basenode = 'xml')
ini_set('zend.ze1_compatibility_mode', 0);
}

if ($structure == NULL)
if ($structure === null)
{
$structure = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$basenode />");
}
Expand Down

0 comments on commit 0a14e87

Please sign in to comment.