Dividing the value in the array and enclosing it in an array separately

Hello,

To watch TV satellites, dish antenna diameters vary according to the satellite coverage area.
Therefore, I am trying to choose satellite dishes suitable for the selected TV satellites.

Satellites List
uydular
I assign Dish antenna diameter and IDs to the checkbox values.

<input type="checkbox" name="secilen_uydu_id[]" class="QUATTRO" value="90-4">

This way it forms a sequence
Array ( [0] => 90-1 [1] => 80-3 [2] => 120-5 [3] => 80-7 )
90, 80, 120, 80 are the satellite dish diameters, 1,2,3,7 are satellite IDs.

I will separate the satellite IDs and assign them to SESSION

Question 1: how do I separate them and create arrays?

My main question is this:
Note: It is the smallest selectable dish diameter for the satellite. larger diameter can be selected
According to the selected satellites, 3 separate satellite dishes should be listed.
1, A table for an 80 Cm dish antenna
2, A table for an 90 Cm dish antenna
3, A table for an 120 Cm dish antenna

120 cm satellite dish can be selected for all satellites X 4 Dish
If it chooses a 90 cm dish antenna, it must choose a 120 cm dish for a satellite (reguired). 90x3+120=4 Dish
If she chooses a 80 cm satellite dish, she can choose a 120 cm dish for the remaining 2 satellites, or 90 cm and 120 cm

This is hard work, can you help?
Thank you from now

$secilen_uydu = explode(filter_input(INPUT_POST, “secilen_uydu_id”));
This will give you an array with 90 and 4 as values. Then, you can use them like this:
$secilen_uydu[0] which is 90 or $secilen[1] which is 4…
Not sure that is what you are asking for…

The next question is confusing. I am guessing it is a language issue. Hard to understand what you are asking us. I see you have 3 sizes. Then, you say some things that do not make sense to me. Like:
if it chooses 90cm it must choose 120cm… In English this does not make sense. As far as the array sequence Array ( [0] => 90-1 [1] => 80-3 [2] => 120-5 [3] => 80-7 ) This can be exploded the same way the first question is. $myArray = Array ( [0] => 90-1 [1] => 80-3 [2] => 120-5 [3] => 80-7 ) and to get them separated, $myValue = explode($myArray[2]); which would give you a new array with 120 and 5 as values in it. Then, use $myValue[1] to get the 5. Not sure if that is what you want either.

Hope this helps…

You are selecting satellite ids, of which there could be a quantity for each id, e.g. someone wants 3 for satellite id 2. That’s the only data that should be submitted from the form. The smallest dish diameter for each id should already be known/stored somewhere on the server. You would use the submitted id values to query to get a list of unique smallest dish diameters. If you only want the dish diameter choices to include those matching the selected satellite ids, you would stop. Otherwise, you would also query to get any dish diameters larger than the smallest not already in the list (your example include a 90 cm choice, but if there wasn’t an id that corresponds to that diameter, it is an available choice that will work and should be displayed in the next step.)

At this point you would have a list of ids (and potentially a quantity of each id) and a list of diameter choices, with a required quantity for each minimum diameter. For your example, you would have 80 (2), 90 (1), 120 (1). I would display these minimum ‘required’ quantities near the choices.

When you validate the submitted dish choices, you would check each time if the existing/previous choices (already in the shopping cart) and the newly submitted choices (form data) satisfies the quantity requirements. If it does, add/update the submitted choices into the cart.

If you are asking how to do that, I would also calculate the maximum quantity for each diameter min/max - 80 (2/2), 90 (1/3), 120 (1/4). If the selected quantity for any diameter is between zero and the maximum, that selection is okay to use (it may not satisfy the whole order, if the user has not finished making choices.). If the selected quantity for any diameter is greater than the maximum, that’s an error. Either limit the quantity to the maximum or require the user to change the selected quantity and re-submit the form. If the total selected quantity of all items is greater than the needed quantity (4 in your example), that’s also an error. You would setup and display a message telling the user that there are too many total items selected. To determine if the selected diameter/quantities satisfies the needed values, you would loop, going from the largest diameter to the smallest, subtracting the minimum need quantity from the selected quality, keeping the remainder for the next smaller diameter loop. At the start of each new loop, just add any remainder from the previous loop (initialized to zero before the start of the first loop) to the selected quantity for the current loop. When you get done, if any of the quantities are greater than zero, you haven’t selected enough items of that or a greater diameter, i.e. you have too many items of a smaller diameter.

I have to do all the operations on the current page

Thank you for your ideas
Some ideas came up, let me test them, I’ll write the result here

Large satellite dish required for some satellites
For some satellites, a small satellite dish is required

A small dish cannot be used for a satellite that requires a large dish.
However, if it is a satellite that requires a small dish antenna, a large one can be used.

Therefore, it is to choose a satellite dish suitable for the selected satellites.

Sponsor our Newsletter | Privacy Policy | Terms of Service