First of all, hello I'm currently making a report system who does take 6 fields(6 selects, all of them being multiples).
I receive their input as a array, and i need process each value for each field
For example, let's give the fields A, B and C.
The field A have the values [1, 2, 3].
The field B have the values [4,5,6].
The field C have the values [7,8,9].
I need make the code run and return like this
1-4-7
1-4-8
1-4-9
1-5-7
1-5-8
1-5-9
( And so on )
Actually, i'm doing this by nesting several foreach's, but i believe it is inefficient(i'm taking almost 30 to 35 seconds to do the loop(without consider the MySQL Query i do inside it)
Does exists a more efficient way to do this?
EDIT
As requested on the comments, i got a example
// I'm ignoring SQL Injection since it is a example only
$status = explode("-", $_POST['status']);
$type = explode("-", $_POST['type']);
$store = explode("-", $_POST['store']);
foreach($status as $statusKey => $statusID) {
foreach($type as $typeKey => $typeID) {
foreach($store as $storeKey => $storeID) {
echo $statusID." - ".$typeID." - ".$storeID.PHP_EOL;
}
}
}