I have an array and through it i wish to fetch values and store them in database.

```
Array
(
    [success] => 1
    [products] => Array
        (
            [0] => Array
                (
                    [id] => 373
                    [categories] => Array
                        (
                            [0] => 1
                            [1] => 15
                            [2] => 28
                        )
                )

            [1] => Array
                (
                    [id] => 210
                    [categories] => Array
                        (
                            [0] => 15
                            [1] => 28
                        )
                )

            [3] => Array
                (
                    [id] => 209
                    [categories] => Array
                        (
                            [0] => 15
                            [1] => 28
                            [2] => 15
                        )
                )

                )

        )
)

```

I have fetched all the data, but now i am facing problem in fetching category. i have table who's view is like this

```
id  prod_id  prod_name  product_catid  product_subcatid

```

In this array the value 15 is for product\_catid and 28 stands for product\_subcatid. 

part of code through which i was fetching values is,

```
if (!empty($array)) 
    {
        foreach ($array['products'] as $product) 
            {
                    if(isset($product['categories']))
                        {
                            $product_catid =  $product['categories'][1];
                            $product_subcatid =  $product['categories'][2];

                            $inserts1 = mysql_query("insert into product_category(prod_id,prod_name,product_catid,product_subcatid,product_subsubcatid) values ('".$idd."','".$product_name."','".$product_catid."','".$product_subcatid."','".$product_subsubcatid."')");

                            $posts[0]['message'] = 'Registered';
                        }

            } 
    } 

```

But the issue is in the second array i.e [1], the value of product\_catid has shifted to [0] index value and product\_subcatid has shifted to [1] index value. 
Now i am stuck and am not able to understand how should i fetch and store values. would appreciate some help.