Question

I am using RedBeanPHP this way:

$banners = R::findAll('banner');

After that i wanted to access each element by its index, says:

$banner1 = $banners[2];

But that way RedBeanPHP try to retrieve a banner which column id = 2 in the database table

What is the way to access elements by the index result?

Was it helpful?

Solution

I found the answer, array_values is the solution:

$banners = R::findAll('banner');
$banners = array_values($banners);
$banner1 = $banners[2];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top