Hello.
I am trying to create arrays of categories for an APP I am developing. Basically, I have an array that holds the identifiers for specific categories. For EG: M40, M60, M70 etc
What I am trying to accomplish is, if the HTML table name starts with a category Identifier, I would like to add that table to an array for that category. For EG: All the tables that start with m40 should go into an array that only holds table names that start with m40, if the table name starts with m60, that table should go into an array that holds tables for the m60 category.
This is the code that I have at the moment, but it is returning an empty array.
for($i=0; $i<count($tables); $i++) {
// If the table name starts with a category identifier in category list, add it to an array for that category
if(strpos($tables[$i], $category_ids[$i]) === 0) {
$last[] = array($tables[$i]);
}
}
So basically I am checking if the tablename starts with m40 or m60 etc, put it into an array that holds the table names that start with that category. So I would have 3 arrays. m40, m60, m70 that each contain the table names that start with the identifier.
The app I am trying to create is the most difficult one I have attempted thus far, so I am struggling quite a lot to make everything work. From my knowledge, the code above SHOULD work, but obviously something is going wrong, and I am not sure what.
If anyone could give any insight to where I am going wrong, or how I should correct it, I would appreciate it!