Answer the question
In order to leave comments, you need to log in
What is the advantage of ArrayObject over Array?
I just can’t understand what the difference is, and the main advantage of ArrayObject over Array.
The model that is requested for data returns an array of objects from the database.
Further already there is a work with an array of objects.
You can also return an ArrayObject, but why and for what I have no idea.
Please provide real examples of ArrayObject, where they are used, in order to sort out this issue once and for all.
Answer the question
In order to leave comments, you need to log in
The model that is requested for data returns an array of objects from the database.
Further already there is a work with an array of objects.
foreach ($model->getArray() as $object) {
// Делаем что-то с $object...
if (!rand(0, 10)) {
break;
}
}
foreach ($model->getIdsArray() as $id) {
// Создаём $object по $id, запросив данные из хранилища
// Делаем что-то с $object...
if (!rand(0, 10)) {
break;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question