lundi 6 janvier 2020

PHP Assign all Pairs of an Array to one unique variable

I have html checkboxes and collect them in an array. I want all pairs of this array (array("A","B","C") -> AB,AC,BC / without BA or CA, because the order doesn't matter) to be assigned to a variable, which will be sent to a database later to increase the value of this particular pair. For example, each time A and B are checked, the value in the database is incremented by 1 as the HTML form is submitted and the query with the unique php variable is sent. The problem is that if there are more than 100 checkboxes and it seems to be impossible to do all this with predefined variables. Does anyone know a trick to create a loop as an alternative to if statements, where php finds all pairs and generates a specific variable.




Aucun commentaire:

Enregistrer un commentaire