I have a function that returns an array and I want to check that a certain value is not set in the array.
function testFunction() {
return array('key' => 404)
}
if (testFunction()['key'] < 404) {
// stay calm and carry on
}
else {
// uh oh
}
I understand that the above will not work in php 5.3 (or anything below), however, I'd like to know what I should do in the above case. That is - what should I call the temporary array I create for the if statement? Or is there another way of dealing with this situation?
The following is what I would roughly do currently:
function testFunction() {
return array('key' => 404)
}
$test_array = testFunction();
if ($test_array['key'] < 404) {
// stay calm and carry on
}
else {
// uh oh
}
Is this an acceptable thing to do?