I got three classes :
class libro {
var $id;
var $name;
var $editorial;
var $materia = array();
[... getters and setters ]
class editorial {
var $name;
var $id;
[...]
class materia {
var $name;
var $id;
[...]
This is working on a website catalogue, where I got an amount of books I get from an xml file. That works well, I checked it; i receive xml values good.
On my website's catalogue, I got a aside bar. By default, are shown all editorials and materias (categories), as well as all books.
So, when I click on a checkbox of one editorial/materia, page reloads with a new query from xml, where one of them are filtered. Books in catalogue are shown, but on the aside, I need to show only the element I checked in, and the other are grouped researching in the new xml query data.
For example, If I select editorial Great Books, page will reload showing only that one editorial on the checkbox, and on aside's section about Materias I will see all that are contained on the array(materia) inside every book, grouped by to not show repeated categories.
The other way of the example :
If I search by a Materia first, editorials on new query will be grouped by too. If I got Editorial selected and I click a category, only category and editorial selected will be shown, and upside down If I selected first the category.
I'm working with $_GET['editorial'] and $_GET['materia'] to work on new query data.
This is my code about grouping...
$bookList = array();
// Here are methods where I set xml data to classes, and I get an array (link below)
$groupedBookList = array();
foreach ($bookList as $book){
// ERROR IN LINE BELOW (Undefined offset: 0 in ...)
$groupBL_Element = &$groupedBookList[$book->get_editorial()->get_id() . "_" .$libro->get_materia(0)->get_id() ];
$groupBL_Element['editorial'] = $book->get_editorial()->get_id();
$groupBL_Element['materia'] = $book->get_materia(0)->get_id();
}
return array_values($groupedBookList);
goo.gl/ 397Wuz
Someone knows some way to group this? Thanks
The error I get is :
Undefined offset: 0 in (line selected by mine up)