At the moment, my script creates referenced keys this:
<?php
$arr = array(
'authority' => $this->object->authority,
'fragment' => $this->object->fragment,
'host' => $this->object->host,
'pass' => $this->object->pass,
'path' => $this->object->path,
'port' => $this->object->port,
'query' => $this->object->query,
'scheme' => $this->object->scheme,
'scheme_name' => $this->object->scheme_name,
'scheme_symbols' => $this->object->scheme_symbols,
'user' => $this->object->user,
);
$arr['domain'] = &$arr['host'];
$arr['fqdn'] = &$arr['host'];
$arr['password'] = &$arr['pass'];
$arr['protocol'] = &$arr['scheme'];
$arr['username'] = &$arr['user'];
ksort($arr);
return $arr;
My question is: there a better way to do this, possibly all in one go?
I know the below code doesn't work, but perhaps someone knows a better way?
<?php
$arr = array(
'a' => '1',
'b' => &$arr['a']
);
get_class_vars()to get an array of all public properties of your class, then assign your array based on those?