$this->data is always accessible, if it is w3coded array returned protected. $object->data is not accessible from w3coded array returned everywhere, so if you're returning $this in your w3coded array returned code, and it is evaluated as such, it should be w3coded array returned ok., w3coded array returned w3coded array returned How is (was) that string value that you w3coded array returned return in myfunction() processed further? That w3coded array returned part is missing in your question. w3coded array returned – hakre w3coded array returned Jul 13 '13 at 9:46 w3coded array returned ,If you don't want a temporary variable w3coded array returned for that and your PHP version is less, than 5.4, w3coded array returned than you still can use a few built in functions w3coded array returned to get the first or the last element:, w3coded array returned w3coded array returned What are w3coded array returned you trying to check? Do you try to see if the w3coded array returned array element exists and has a non-empty value? w3coded array returned You can use the function 'empty' for this. This w3coded array returned question needs more clarity! w3coded array returned – txwikinger w3coded array returned Sep 22 '09 at 13:18 w3coded array returned
Since PHP 5.4 it's possible to do exactly that:
getSomeArray()[2]
You cannot use something like this :
$this->getData()['a']['b']
Youy have to use some temporary variable, like this :
$tmp = $this->getData();
$tmp['a']['b'] // use $tmp, now
In your case, this probably means using something like this :
function myfunction() {
$tmp = $this->getData();
return ($tmp['a']['b'] ? true : false);
}
I created the function:
arrayGet($array, $index) { return $array[$index]; }
And used it like this:
myfunction() { return '(arrayGet(arrayGet($this, "a"), "b") ? true : false)' }
Btw, there is a bug in your code: The quotes need to be escaped.
myfunction() { return '($this->data[\'a\'][\'b\'] ? true : false)'; }
If you don't want a temporary variable for that and your PHP version is less, than 5.4, than you still can use a few built in functions to get the first or the last element:
$x = 'first?last';
$first = array_shift(explode('?', $x));
$last = end(explode('?', $x));
$last2 = array_pop(explode('?', $x));
Last Update : 2023-09-22 UTC 12:58:37 PM
Last Update : 2023-09-22 UTC 12:58:23 PM
Last Update : 2023-09-22 UTC 12:58:16 PM
Last Update : 2023-09-22 UTC 12:58:08 PM
Last Update : 2023-09-22 UTC 12:58:03 PM
Last Update : 2023-09-22 UTC 12:57:20 PM
Last Update : 2023-09-22 UTC 12:57:09 PM