How about add this function? For example end($model->array) or if array is return result will not work
I think you need PHP function end()
Read carefull, end not work on $model->data
It return error Indirect modification of overloaded property app\models\Class::$data has no effect
Also end not work if array is returned value of function
or you have PROBLEMS WITH READING OR UNDERSTANDING?
So you want a helper for 2 lines of code:
$array = $model->data;
$lastValue = end($array);
?
or you have PROBLEMS WITH READING OR UNDERSTANDING?
I do have problems with understanding, when the message is badly-composed. The original message spelling is confusing, so I didn't get it correctly. Please, follow the Code of conduct.
Agreed with @rob006
@rob006 why not put this to ArrayHelper?
@nicdnepr You're asking wrong question. You should as why we should put this into helper? There are thousands 2-liners that could be added to helpers as a separate methods, but we definitely don't want a helpers with thousands of methods, so simple "why not" is not a reason to add a new method.
Most helpful comment
@nicdnepr You're asking wrong question. You should as why we should put this into helper? There are thousands 2-liners that could be added to helpers as a separate methods, but we definitely don't want a helpers with thousands of methods, so simple "why not" is not a reason to add a new method.