Is it possible to reference the currently executing array from within an array?
I would like to do the following, for example (I used the $this keyword to clarify what I mean, which I need a substitue for obviously):
function somefunction(string $data_string) {
return array(
"data" => explode($data_string, "/"),
"key1" => reset($data_string) !== false ? array_shift($this->"data") : "do something else",
etc...
);
}
I could of course solve this by doing the following:
function somefunction(string $data_string) {
$var["data"] = explode($data_string, "/");
$var["key1"] = reset($data_string) !== false ? array_shift($var["data"]) : "do something else";
etc...
return $var;
}
But it feels as if creating the extra variable $var is unnecessary.