Jump to content

soyaslim

Members
  • Posts

    19
  • Joined

  • Last visited

Posts posted by soyaslim

  1. Hi @requinix , Thank you for your explanation and for taking the time to solve this problem. The whole recursive approach I really do not follow that method because I find it really confusing and hard, however, I am able to break it through my existing solution. Below I have simply break the loop if the `vehicle_info` `key` does not match 
     

    $commonArray = [];
    $total = count($products) - 1;
    
    $vehicles = $products[0];
    array_shift($products);
    
    foreach ($vehicles as $key => $vehicle) {
        foreach ($vehicle['vehicle_info'] as $ktype => $fitments) {
            $countKey = 0;
            // check all the products
            foreach ($products as $index => $product) {
                if (!isset($product[$key]['vehicle_info'])) {
                    // key not found in this product, move on to next key
                    break 2;
                }
    
                foreach ($product[$key]['vehicle_info'] as $kt => $fits) {
                    if ($ktype == $kt) {
                        $countKey++;
                        if ($countKey == $total) {
                            $commonArray[$key] = $product[$key];
                        }
                    }
                }
            }
        }
    }
    
    print_r($commonArray);

     

  2. 56 minutes ago, requinix said:

    All you really need is some sort of "array_intersect_recursive", because the exact structure of the $products doesn't actually change how you compare the different parts of it to others, but unfortunately PHP doesn't have that built-in and implementing it yourself is a bit complicated.

    A quick improvement is that you can array_shift($products) to remove the first one from the array and return it back to you. Means you don't need to skip $index 0 anymore.

    A more complicated improvement would be to adjust your approach: rather than count how many times something appears before adding it, it would save some processing time if you immediately bailed out when you discovered that something did not appear. As in:

    $commonArray = [];
    $first = array_shift($products);
    foreach ($first as $key => $vehicle) {
    	$commonVehicle = [];
    
    	// check if $key exists in all the other $products
    	// if not, use continue (likely a continue 2; or continue 3;) to skip ahead of this loop here and go to the next $key
    	// if so, build up the contents of $commonVehicle...
    
    	if ($commonVehicle) {
    		// only add this $key if there is something to add
    		$commonArray[$key] = $vehicle;
    	}
    }

    And like I said, while the keys of $products changes as you dig into it, you're repeating the same "check if <key> exists in other <arrays>" all the way down, so you'd basically just repeat the above code a couple more times with different variable names.

    Hi @requinix Thanks for your feedback and suggestion and clean code. However, I need to check the vehicle info`key` which is `123`, `234` so on as well before adding to commonArray. I added the condition to your code like below. But it only check the `key` but not the vehicle info `key`.

    $commonArray = [];
    $first = array_shift($products);
    foreach ($first as $key => $vehicle) {
    	$commonVehicle = [];
        
        foreach ($products as $product) {
            foreach ($product as $k => $pro) {
                // check if $key exists in all the other $products
                if ($key == $k) {
                    // if so, build up the contents of $commonVehicle...
                    $commonVehicle[$key] = $pro;
                } else {
                    // if not, use continue (likely a continue 2; or continue 3;) to skip ahead of this loop here and go to the next $key
                    continue 2;
                }
            }
        }
    
    	if ($commonVehicle) {
    		// only add this $key if there is something to add
    		$commonArray[$key] = $vehicle;
    	}
    }
    
    print_r($commonArray);

     

  3. Hello guys, How r we? I am trying to manipulate multi-dimension array to the desired array. So, I have this array $products that have three `elements`. Lets say the element as`product` so, three products.

    $products = [
        [
            'test' => [
                'make' => 'test make',
                'vehicle_info' => [
                    '123' => [
                        'brake' => 'brake 123 value'
                    ],
                    '234' => [
                        'brake' => 'brake 234 value'
                    ]
                ]
            ],
            'test2' => [
                'vehicle_info' => [
                    '456' => [
                        'brake' => 'brake 456 value'
                    ],
                    '678' => [
                        'brake' => 'brake 678 value'
                    ]
                ]
            ]
        ],
        [
            'test' => [
                'make' => 'test make',
                'vehicle_info' => [
                    '234' => [
                        'brake' => 'brake 234 value'
                    ]
                ]
            ],
            'test2' => [
                'vehicle_info' => [
                    '456' => [
                        'brake' => 'brake 456 value'
                    ]
                ]
            ],
            'test3' => [
                'vehicle_info' => [
                    '789' => [
                        'brake' => 'brake 789 value'
                    ]
                ]
            ]
        ],
        [
            'test' => [
                'make' => 'test make',
                'vehicle_info' => [
                    '234' => [
                        'brake' => 'brake 234 value'
                    ]
                ]
            ],
            'test3' => [
                'vehicle_info' => [
                    '789' => [
                        'brake' => 'brake 789 value'
                    ]
                ]
            ]
        ]
    ];

    So, here is the desired output of the common array between 3 products. Since, the key `test` is common in all three products and `234` is common within `test` array in all three products.
     

    Array
    (
        [test] => Array
            (
                [make] => test make
                [vehicle_info] => Array
                    (
                        [234] => Array
                            (
                                [brake] => brake 234 value
                            )
    
                    )
    
            )
    
    )

    So, the solution I have works fine but I want to optimize my code or to improve it as much as possible. Please let me know if the steps are not clear.
     

    $commonArray = [];
    $total = count($products) - 1;
    
    
    $vehicles = $products[0];
    foreach ($vehicles as $key => $vehicle) {
        foreach ($vehicle['vehicle_info'] as $ktype => $fitments) {
            $countKey = 0; // keep track of key exists in all products
            // loop through all the products
            foreach ($products as $index => $product) {
                if ($index == 0) // skip the first product
                    continue;
    
                foreach ($product as $k => $pro) {
                    if ($key == $k) {
                        foreach ($pro['vehicle_info'] as $kt => $fits) {
                            if ($ktype == $kt) {
                                $countKey++;
                                if ($countKey == $total) { // check if the key exists in all products
                                    $commonArray[$key] = $pro;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    
    print_r($commonArray);


     

  4. I am currently working on a simple task yet a bit tricky. My task is to read all the images from the directory and write them into CSV file. So, when I read the directory I get the array list of images filename data will look like below:

    array (
        '13763',
        '13763-1',
        '13763-2',
        '13764',
        '13765',
        '13765-1',
    );

    I wanted this data to be exported into csv file which looks like below:

    image.png.1ab8bb640132de833a689b0267a2830d.png

    So, I am going through the foreach loop as $image which gives me each element and each loop I am checking the string has '-' character or not. If it has no '-' character than I assign $currentId = $image but if it has '-' then I append $additionalImage .= ', '.$image.'.jpg'. But I have an issue when accessing the $additionalImage. Below is my code what I have done so far.

    $currentId = '';
    $prevId = '';
    $additionalImages = '';
    $addId = '';
    $counter = 0;
    
    $file = fopen('./images/M2_import_image.csv', 'w');
    
    foreach ($images as $image) {
    
        
        if (strpos($image, '-') == FALSE) {
            if ($currentId != $image) {
                $mainImage = $image.'.jpg';
                // print_r($additionalImages);
                fputcsv($file, array(
                   $mainImage,
                   $mainImage,
                   $mainImage,
                   $mainImage,
                   $mainImage,
                   $additionalImages,
                ));
                $additionalImages = '';
            }
            $currentId = $image;
            $additionalImages = $image.'.jpg';
        }
    
        if (strpos($image, '-') != FALSE) {
            $addId = substr($image, 0, strpos($image, '-'));
            $additionalImages .= ', '.$image.'.jpg';
        }
    
    }
    fclose($file);

     

  5. 5 hours ago, requinix said:

    Hmm, looks like you'll need a modification or two to the array I suggested. More like

    array(
    	13763 => array(
    		"base_image" => "13763.jpg",
    		"additional_images" => array(
    			"13763-1.jpg",
    			"13763-2.jpg"
    		)
    	),

    0. Start with an empty array for you to store the lists of additional files you'll be building.
    1. Use glob() to get the list of files. It already comes sorted in ascending order, you need it sorted in ascending order, and I'm not sure why you want to sort it in reverse order.
    2. Use pathinfo() to get the different parts of the file name. Look at the different parts it returns because you'll want more than one of them.
    3. If the filename-without-extension portion is just a number then add an entry to the array. You know the base_image value already. Start with the additional_images empty.
    4a. If the filename-without-extension portion is not just a number then split it into (1) the initial number and (2) the hyphen and everything after it.
    4b. Look for an entry in the array for the number. If it exists then add the file to the additional_images array. If not then I don't know what you want to do.

    At the end of this, you should have an array that looks like the sample above...

    Could u please shed a light on me? I really appreciate your help and the time u had already spent. So, I manage to change the images filenames array that I got from the directory, I first replace the extension '.jpg' and directory name '/images' and sorted the array as below:
     

    array (
        '13763',
        '13763-1',
        '13763-2',
        '13764',
        '13765',
        '13765-1',
    );

    So, I am going through the foreach loop as $image which gives me each element and each loop I am checking the string has '-' character or not. If it has no '-' character than I assign $currentId = $image but if it has '-' then I assign $additionalImage .= ', '.$image.'.jpg'. But the problem is I only want to insert one row if it has additional images '13763.jpg, 13763-1.jpg, 13763-2.jpg'. Below is my code what I have done so far.
     

    
    $currentId = '';
    $additionalImages = '';
    $addId = '';
    
    foreach ($images as $image) {
       
        if (strpos($image, '-') == FALSE) {
            $currentId = $image;
            $additionalImages = $image.'.jpg';
        }
    
        if (strpos($image, '-') != FALSE) {
            $addId = substr($image, 0, strpos($image, '-'));
            $additionalImages .= ', '.$image.'.jpg';
        }
    
        
        // insert into csv file
    
    }

     

  6. 37 minutes ago, requinix said:

    I think I'm getting an aneurysm.

    What you're describing does not seem to match what the screenshot of the file shows. I think what you actually want to do is (1) find all the files in the directory, (2) group them by the initial number in the name, then (3) sync up the CSV file according to the new set of files. But what to do with files in the CSV that aren't in the directory? Seems you want to discard them?

    So one step at a time. You need to get an array - one that is not $additionalImages but something entirely different - which has a list of all the files grouped by that initial number. With your example, it will look like

    array(
    	"13763.jpg" => array(
    		"13763-1.jpg",
    		"13763-2.jpg"
    	),
    	"13764.jpg" => array(
    		"13764-1.jpg",
    		"13764-2.jpg"
    	),
    	"13765.jpg" => array()
    )

    That means there is a 13763.jpg with two additional files, 13764.jpg with two more additional files, and 13765.jpg without any additional files.

    Once you have that then you can move onto the next step of writing it to the file...

    Is there any way I can achieve this? I checked if the array data has "-" and matches the id but did not able to do it.

  7.  I tried to check if the next array data has '-' or rolanId in the string but still could not achieve the array.
     

    10 minutes ago, soyaslim said:

    You are exactly right! but how do I achieve this array

    foreach ($images as $image) {
            $filename = pathinfo($image);
            $filename = $filename['filename']; // 13763
            $rolanId = substr($filename, 0, strpos($filename, '-')); // 13763
            
            $additionalImages[] = $rolanId.'.jpg';
            $csvData[$rolanId] = array(
                $rolanId.'.jpg',
                (strpos($filename, "-") != FALSE)? $filename : '',
            );
            
        }
        print_r($csvData);

     

  8. 4 minutes ago, requinix said:

    I think I'm getting an aneurysm.

    What you're describing does not seem to match what the screenshot of the file shows. I think what you actually want to do is (1) find all the files in the directory, (2) group them by the initial number in the name, then (3) sync up the CSV file according to the new set of files. But what to do with files in the CSV that aren't in the directory? Seems you want to discard them?

    So one step at a time. You need to get an array - one that is not $additionalImages but something entirely different - which has a list of all the files grouped by that initial number. With your example, it will look like

    array(
    	"13763.jpg" => array(
    		"13763-1.jpg",
    		"13763-2.jpg"
    	),
    	"13764.jpg" => array(
    		"13764-1.jpg",
    		"13764-2.jpg"
    	),
    	"13765.jpg" => array()
    )

    That means there is a 13763.jpg with two additional files, 13764.jpg with two more additional files, and 13765.jpg without any additional files.

    Once you have that then you can move onto the next step of writing it to the file...

    You are exactly right! but how do I achieve this array

  9. Hello guys, I have been working on this simple project, however, seems a little bit tricky. So, I have an array which I want to write the data into csv file. The array below:
     

    Array
    (
        [0] => 13763-1.jpg
        [1] => 13763.jpg
        [2] => 13763-2.jpg
        [3] => 13764-2.jpg
        [4] => 13764.jpg
        [5] => 13764-1.jpg
        [6] => 13765.jpg
    )
    
    

    I sorted the array using rsort($array) so it looks like below:

    Array
    (
        [0] => 13765.jpg
        [1] => 13764.jpg
        [2] => 13764-2.jpg
        [3] => 13764-1.jpg
        [4] => 13763.jpg
        [5] => 13763-2.jpg
        [6] => 13763-1.jpg
    )

    So, I want to output this data into csv file like below:

    image.png.c3fb0823690a103668d47351570751fd.png

    However, I could not able to achieve the additional images value in the CSV data. My code below:

    $file = fopen($directory."M2_import_image.csv", 'w');
    
        // insert header to import file
        $header= array("product_id", "base_image", "small_image", "thumbnail_image", "swatch_image", "additional_images");
        fputcsv($file, $header, ',');
    
        $images = glob($directory.'*.{jpg,png,gif,jpeg,JPG}', GLOB_BRACE);
        rsort($images);
        // natcasesort($images);
       
        $csvData = [];
        $counter = 0;
        foreach ($images as $image) {
            $filename = pathinfo($image);
            $filename = $filename['filename'];
            $rolanId = substr($filename, 0, strpos($filename, '-'));
            
            $additionalImages[] = $rolanId.'.jpg';
    
            if (strstr($filename, $rolanId) != FALSE) {
                $counter++;
            } else if (strstr($filename, $rolanId) == FALSE)
                $counter = 0;
    
            if ($counter > 0) {
               $additionalImages[] = $filename.'.jpg';
            } 
            
        }
        print_r($additionalImages);
    
        fclose($file);

     

  10. On 8/18/2022 at 10:27 AM, kicken said:

    Turn your first array into a map, so it would look like this:

    Array
    (
        [ROLAN] => 3.8
        [COOLDRIVE] => 6.2
        [ENGINEERING.] => 14.6
        [TEST DEPO] => 9
    )

    You can use a loop or array_column to accomplish that.

    Then you can simply look up the supplier in that map by accessing the appropriate index rather than having to loop and search for it.

    $supplierAvailable[$row['supplier']]['distance'] = $distanceMap[$row['supplier']]

     

    Hey Kicken, actually the array 'supplier' value has a single quote like below

    Array
    (
        [0] => Array
            (
                [supplier] => 'ROLAN'
                [distance] => 3.8
            )

    so, the it does not match the following code as ROLAN is not equal to 'ROLAN'

    $supplierAvailable[$row['supplier']]['distance'] = $distanceMap[$row['supplier']]

     

  11. Hello guys, I have this array that I want the 'distance' key value to another array if this array 'supplier' matches the other array 'supplier' value.

    Array
    (
        [0] => Array
            (
                [supplier] => 'ROLAN'
                [distance] => 3.8
            )
    
        [1] => Array
            (
                [supplier] => 'COOLDRIVE'
                [distance] => 6.2
            )
    
        [2] => Array
            (
                [supplier] => 'ENGINEERING.'
                [distance] => 14.6
            )
    
        [3] => Array
            (
                [supplier] => 'TEST DEPO'
                [distance] => 9.0
            )
    
    )

    The other array is So, I just want to add 'distance' from the top array to below which I did already with the foreach loop.

    Array
    (
        [0] => Array
            (
                [supplier] => ENGINEERING
                [rolanID] => Array
                    (
                        [0] => 51154
                    )
            )
    
        [1] => Array
            (
                [supplier] => COOLDRIVE
                [rolanID] => Array
                    (
                        [0] => 2338117
                    )
            )
    
        [2] => Array
            (
                [supplier] => ROLAN
                [rolanID] => Array
                    (
                        [0] => 2338117
                        [1] => 51154
                    )
    
            )
    
    )

    So, Is there any best way than this below my code: Thank you

    foreach ($results as $row) {  // this is second array loop
                $supplierAvailable[$row['supplier']]['supplier'] = $row['supplier'];                      
                $supplierAvailable[$row['supplier']]['rolanID'][] = $row['rolan_part_id'];
                
                foreach ($supplierDetails as $index => $depo) { // this is  the first array loop to add distance to second array
                    if ($depo['supplier'] == "'".$row['supplier']."'") {
                        $supplierAvailable[$row['supplier']]['distance'] = $depo['distance'];
                        unset($depo[$index]);
                        break;
                    }
                }
            }

     

  12. 4 minutes ago, Barand said:

    Using your new $test array with my code, I get this in the $test array...

    Array
    (
        [0] => Array
            (
                [supplier] => ROLAN
                [rolanID] => Array
                    (
                        [0] => 456
                    )
    
                [itemCount] => 1
            )
    
        [1] => Array
            (
                [supplier] => ROLAN
                [rolanID] => Array
                    (
                        [0] => 123
                        [1] => 234
                    )
    
                [itemCount] => 2
            )
    
        [3] => Array
            (
                [supplier] => DIFFERENT DEPO
                [rolanID] => Array
                    (
                        [0] => 897
                        [1] => 487
                        [2] => 100
                    )
    
                [itemCount] => 3
            )
    
        [4] => Array
            (
                [supplier] => TEST2 DEPO
                [rolanID] => Array
                    (
                        [1] => 188
                        [2] => 200
                    )
    
                [itemCount] => 2
            )
    
    )

     

    Sorry Barand, I actually sorted by 'itemCount' before this so I sorted the array first by following code:
     

    usort($test, function ($a, $b) {
            if ($a['itemCount'] > $b['itemCount']) {
                return -1; 
            } else 
                return 1;
        });

     

  13. 58 minutes ago, Barand said:

    Here's my solution

        $seen = [];
        foreach ($test as $k => &$rec) {
            $rec['rolanID'] = array_diff($rec['rolanID'], $seen);          // find new ids 
            if ($rec['rolanID']) {                                         // if there are some new ones ...
                $rec['itemCount'] = count($rec['rolanID']);                   // count them
                $seen = array_merge($seen, $rec['rolanID']);                  // add the new ones to those already seen
            }
            else unset($test[$k]);                                         // if no ids, remove the array item
        }
    +-----------------------------------------------+
    |                                               |
    |    $test ARRAY - AFTER                        |
    |                                               |
    +-----------------------------------------------+
    |                                               |
    |     Array                                     |
    |     (                                         |
    |         [0] => Array                          |
    |             (                                 |
    |                 [supplier] => TEST DEPO       |
    |                 [rolanID] => Array            |
    |                     (                         |
    |                         [0] => 123            |
    |                         [1] => 234            |
    |                         [2] => 456            |
    |                     )                         |
    |                                               |
    |                 [itemCount] => 3              |
    |             )                                 |
    |                                               |
    |         [1] => Array                          |
    |             (                                 |
    |                 [supplier] => ANOTHER DEPO    |
    |                 [rolanID] => Array            |
    |                     (                         |
    |                         [1] => 786            |
    |                         [2] => 345            |
    |                     )                         |
    |                                               |
    |                 [itemCount] => 2              |
    |             )                                 |
    |     )                                         |
    |                                               |
    +-----------------------------------------------+

     

    Hi Barand, Could u shed a light on me? I used ur code with another case of data but there was a duplicate rolanID in one of the array.
     

    $test = array(
            array(
                "supplier" => "ROLAN",
                "rolanID" => array(456),
                "itemCount" => 1,
            ),
            array(
                "supplier" => "ROLAN",
                "rolanID" => array(123, 234),
                "itemCount" => 2,
            ),
            array(
                "supplier" => "TEST DEPO",
                "rolanID" => array(123, 234, 456),
                "itemCount" => 3,
            ),
            array(  
                "supplier" => "DIFFERENT DEPO",
                "rolanID" => array(897, 487, 100),
                "itemCount" => 3,
            ),
            array(
                "supplier" => "TEST2 DEPO",
                "rolanID" => array(456, 188, 200, 123),
                "itemCount" => 4,
            )
        );

    So, I tried using this data and the output was below using ur code.

    Array
    (
        [0] => Array
            (
                [supplier] => TEST2 DEPO
                [rolanID] => Array
                    (
                        [0] => 456
                        [1] => 188
                        [2] => 200
                        [3] => 123
                    )
    
                [itemCount] => 4
            )
    
        [1] => Array
            (
                [supplier] => DIFFERENT DEPO
                [rolanID] => Array
                    (
                        [0] => 897
                        [1] => 487
                        [2] => 100
                    )
    
                [itemCount] => 3
            )
    
        [2] => Array
            (
                [supplier] => TEST DEPO
                [rolanID] => Array
                    (
                        [0] => 123
                        [1] => 234
                        [2] => 456
                    )
    
                [itemCount] => 3
            )
    
    )

    Since the supplier 'TEST2 DEPO' has already rolanID '123' so, is it possible to remove the duplication in any other supplier? For example in this case, the rolan ID '123' is duplicated in last element of array supplier 'TEST DEPO'. 

  14. On 8/12/2022 at 5:05 PM, requinix said:

    Start with a blank array where you'll hold all the previous rolanIDs that you have "seen" associated with other suppliers.

    Then loop through your $test array. For each supplier, look at each of their rolanIDs. If the value exists in the "seen" array then unset it in the supplier's array. If not then add it to the "seen" array.
    When you've looked through a supplier's rolanIDs, check if that array is now empty (because you removed everything in it). If so, remove the entire supplier from your $test array.

    Questions? Try writing code for that. If you have problems, post the code you've written so far and tell us about what's going wrong.

    $finalArray[] = $test[0];
                for ($i=1; $i<count($test); $i++) {
                    $id = array_diff($test[$i]['rolanID'], $test[0]['rolanID']);
    
                    if (!empty($id)) {
                        array_push($finalArray, array(
                            'supplier' => $test[$i]['supplier'],
                            'rolanID' => $id,
                            'address' => $test[$i]['address'],
                            'itemCount' => count($id),
                        ));
                    } 
                }

    This is how I tried but it does not work in some cases. For example, it only checks the first element of array with others. So, there will be multiple arrays with same rolanID that doesnot exists in first element of array.

  15. Hello guys, I have a multidimensional array and I want to change it to my final array. Below is the array I have.

    $test = array(
                array(
                    "supplier" => "TEST DEPO",
                    "rolanID" => array(123, 234, 456),
                    "itemCount" => 3
                ),
                array(
                    "supplier" => "ANOTHER DEPO",
                    "rolanID" => array(123, 786, 345),
                    "itemCount" => 3
                ),
                array(
                    "supplier" => "ROLAN",
                    "rolanID" => array(123, 234),
                    "itemCount" => 2
                ),
                
            );

    So, with this array I want to output like the below array. As we can see, if all rolanID is equal to one of the supplier then I don't want to add that array into the final array. For, an example the supplier "ROLAN" array is removed completely in the final array as its all rolanID is in the supplier "TEST DEPO" but the supplier "ANOTHER DEPO" has some rolanID that is not in the supplier "TEST DEPO" so, it is included that in the final array.

    Array
    (
        [0] => Array
            (
                [supplier] => TEST DEPO
                [rolanID] => Array
                    (
                        [0] => 123
                        [1] => 234
                        [2] => 456
                    )
    
                [itemCount] => 3
            )
    
        [1] => Array
            (
                [supplier] => ANOTHER DEPO
                [rolanID] => Array
                    (
                        [0] => 786
                        [1] => 345
                    )
    
                [itemCount] => 2
            )
    
    )

     

  16. for ($i=0; $i<count($results)-1; $i++) {
                $productID = ($results[0]['supplier'] == $results[$i+1]['supplier']) ? array($results[$i]['rolan_part_id'], $results[$i+1]['rolan_part_id']) : array($results[$i+1]['rolan_part_id']);
                $finalArray[$results[$i]['supplier']] = array(
                    "productID" => $productID,
                );
            }
            print_r($finalArray);

    so, the $results contain the array I want to change, which is three nested arrays. The above output is:

    Array
    (
        [COOLDRIVE DISTRIBUTION] => Array
            (
                [productID] => Array
                    (
                        [0] => 2338117
                    )
    
            )
    
        [ROLAN] => Array
            (
                [productID] => Array
                    (
                        [0] => 51154
                    )
    
            )
    
    )

    I couldn't get the other productID in 'ROLAN' array.

  17. Hello guys. I want the array to be processed into my final array how am I supposed to achieve this. Below is the array I want to process.

    Array 
    (
        Array
          (
              [part_id] => 2338117
              [supplier] => COOLDRIVE DISTRIBUTION
              [quantity] => 12
          )
        Array
          (
              [part_id] => 2338117
              [supplier] => ROLAN
              [quantity] => 20
          )
        Array
          (
              [part_id] => 51154
              [supplier] => ROLAN
              [quantity] => 20
          )
    )

    This is the final array I want.

    Array
    (
        [COOLDRIVE DISTRIBUTION] => Array 
              (
                  [proudctID] => Array 
                         (
                             [0] => 2338117
                         )
               )
        [ROLAN] => Array 
               (
                   [productID] => Array 
                      (
                           [0] => 2338117
                           [1] => 51154
                      )
               )
    )

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.