简体   繁体   中英

php csv dynamic columns

I'm design a shopping cart that will allow users to upload products in csv format. The problem is that one of the columns contains dynamic sub columns. The best way to explain this is an example of a product data:

stdClass Object
(
    [id] => 412
    [description] => this is the description for phat cars

    [title] => Phat Cars
    [price] => 2500.00
    [custom] => Array
        (
            [custom_info] => Array
                (
                )

            [custom_price] => Array
                (
                )
        )

)

The field custom[custom_info] and custom[custom_price] could contain any number of fields. I can't think of a solution to have dynamic columns using csv but thought I'd throw the problem out there and see if anybody has any suggestion.

You can invent a different notation for this special column - defferent delimiter or json. But this will be hard to write in excel.

I had the same problem once where we had to import courier deliveries with any number of sub-packages. So we allowed to create only one sub-package via CSV and as many as you like via web site.

A better way would be to import this data via WEB services.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM