How can php generate rules faster (combination)

question: rules need to be generated according to some conditions, for example, there are 3 areas (area A, B, C) and three streets (A Street, B Street, C Street), then there will be 9 rules generated, as follows:

1A area A street
2A area B street
3A area C street

4 B area A Street
5 B area B Street
6 B area C Street

7 C area A Street
8 C area B Street
9 C area C Street

above are the 9 generated rules,

is there anything else you can do but nested loops, gods?

if there are more conditions to generate, then the nested loop estimation is not good, it is too tedious.

Php
Jul.22,2021

learn about it recursively

write a simple one

  

I went to look at the function in laravel that calculates Cartesian product, and it still seems to be a nested loop at the bottom!

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea8ac6-1ef1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea8ac6-1ef1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?