I'm creating the array dynamically using this tool.
http://174.121.67.116/~achadire/aware5/product_options.php?cid=6
The array output looks like this.
$data = array(
0 => array(
0 => 300,
3 => 186,
),
1 => array(
0 => 341,
3 => 186,
),
2 => array(
0 => 257,
3 => 186,
),
3 => array(
0 => 300,
3 => 360,
),
4 => array(
0 => 300,
3 => 187,
),
5 => array(
0 => 341,
3 => 360,
),
6 => array(
0 => 341,
3 => 187,
),
7 => array(
0 => 257,
3 => 360,
),
8 => array(
0 => 257,
3 => 187,
),
);
0 => Array is the product. [0]=>300, [2]=>186 represent a unique product configuration for the given array key. (i.e blue, big.) (each vale is a id for an attribute.)
So I want to upload the results to products table in MySQL. Here is my problem:
First, how do I make my array key a unique 7 digit product code. In other words, how to I reindex my array with a unique 7 digit code so that I never use the same key for an array twice. I assume this means figuring out the next value in the mysql database and then looping through the array with i++ before pushing to the table.
Second, the same configuration should only be applied to one product. So if the array key combination already exists it should skip to the next array.
In short how do I turn my array key into a unique 7 digit product code? Also, when I upload my array how to I skip over values combinations that already exists in the database so I don't have two different product codes with the same configuration.