mysql-php Excel Import Import level Three classification table what should I do to get the data format you want?

Source: Internet
Author: User
Tags php excel

Is that there are more than 1 levels of classification under the uncertainty of the class two category two classification below there is an indeterminate level three classification I want to get the relevant data combination to write to the database but this format does not know how to get the right data
Give me a hand, please.

Is there a way to get the value of an entire column and then differentiate 2 columns based on length and then differentiate three columns

The data format that is now obtained is 1 2 3 by line ...

The data printed on the

Array (size=16) 0 = array (size=7) 0 = float 1 1 = string ' Sales ' (length=9) 2 = string     ' Sales 1 zone ' (length=10) 3 = String ' Sales 1 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = null 1 =  Array (size=7) 0 = float 2 1 = null 2 = null 3 = String ' Sales 2 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = null 2 = Array (size=7) 0 = float 3 1 = null 2 = NULL 3 = String ' Sales 3 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = NULL 3 = Arra Y (size=7) 0 = float 4 1 = null 2 = null 3 = String ' Sales 4 Department ' (length=13) 4 = n ull 5 = NULL 6 = NULL 4 = array (size=7) 0 = float 5 1 = null 2 = St Ring ' Sales Zone 2 ' (length=10) 3 = String ' Sales 1 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = NULL 5 = > Array (size=7)     0 = Float 6 1 = null 2 = null 3 = String ' Sales 2 Department ' (length=13) 4 = null 5 = NULL 6 = NULL 6 = array (size=7) 0 = float 7 1 = null 2 = NULL 3 = > String ' Sales 3 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = NULL 7 = array (size=7) 0 = > float 8 1 = null 2 = null 3 = String ' Sales 4 Department ' (length=13) 4 = null 5 = Nu LL 6 = null 8 = array (size=7) 0 = float 9 1 = string ' marketing ' (length=9) 2 = St Ring ' Market Zone 1 ' (length=10) 3 = String ' Market 1 Departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = NULL 9 =      > Array (size=7) 0 = float 1 = null 2 = null 3 = String ' Market 2 departments ' (LENGTH=13)       4 = NULL 5 = NULL 6 = NULL = Array (size=7) 0 = float 1 = null      2 = null3 = String ' Market 3 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = null one, and array (size=7) 0 = float 1 = null 2 = null 3 = String ' Market 4 Department ' (length=13) 4 = null 5 =&G T NULL 6 = NULL 1 = array (size=7) 0 = float = null 2 = String ' Market 2 ' (le  ngth=10) 3 = String ' Market 1 Departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = null-= = Array (size=7) 0 = float 1 = null 2 = null 3 = String ' Market 2 Department ' (length=13) 4 = n ull 5 = NULL 6 = null 2 = Array (size=7) 0 = float 1 Null 3 = String ' Market 3 Department ' (length=13) 4 = NULL 5 = NULL 6 = null \ = Array (si      ze=7) 0 = float 1 = null 2 = null 3 = String ' Market 4 Department ' (length=13) 4 = null    5 = null  6 = null 

Reply content:

Is that there are more than 1 levels of classification under the uncertainty of the class two category two classification below there is an indeterminate level three classification I want to get the relevant data combination to write to the database but this format does not know how to get the right data
Give me a hand, please.

Is there a way to get the value of an entire column and then differentiate 2 columns based on length and then differentiate three columns

The data format that is now obtained is 1 2 3 by line ...

The data printed on the

Array (size=16) 0 = array (size=7) 0 = float 1 1 = string ' Sales ' (length=9) 2 = string     ' Sales 1 zone ' (length=10) 3 = String ' Sales 1 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = null 1 =  Array (size=7) 0 = float 2 1 = null 2 = null 3 = String ' Sales 2 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = null 2 = Array (size=7) 0 = float 3 1 = null 2 = NULL 3 = String ' Sales 3 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = NULL 3 = Arra Y (size=7) 0 = float 4 1 = null 2 = null 3 = String ' Sales 4 Department ' (length=13) 4 = n ull 5 = NULL 6 = NULL 4 = array (size=7) 0 = float 5 1 = null 2 = St Ring ' Sales Zone 2 ' (length=10) 3 = String ' Sales 1 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = NULL 5 = > Array (size=7)     0 = Float 6 1 = null 2 = null 3 = String ' Sales 2 Department ' (length=13) 4 = null 5 = NULL 6 = NULL 6 = array (size=7) 0 = float 7 1 = null 2 = NULL 3 = > String ' Sales 3 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = NULL 7 = array (size=7) 0 = > float 8 1 = null 2 = null 3 = String ' Sales 4 Department ' (length=13) 4 = null 5 = Nu LL 6 = null 8 = array (size=7) 0 = float 9 1 = string ' marketing ' (length=9) 2 = St Ring ' Market Zone 1 ' (length=10) 3 = String ' Market 1 Departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = NULL 9 =      > Array (size=7) 0 = float 1 = null 2 = null 3 = String ' Market 2 departments ' (LENGTH=13)       4 = NULL 5 = NULL 6 = NULL = Array (size=7) 0 = float 1 = null      2 = null3 = String ' Market 3 departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = null one, and array (size=7) 0 = float 1 = null 2 = null 3 = String ' Market 4 Department ' (length=13) 4 = null 5 =&G T NULL 6 = NULL 1 = array (size=7) 0 = float = null 2 = String ' Market 2 ' (le  ngth=10) 3 = String ' Market 1 Departments ' (LENGTH=13) 4 = NULL 5 = NULL 6 = null-= = Array (size=7) 0 = float 1 = null 2 = null 3 = String ' Market 2 Department ' (length=13) 4 = n ull 5 = NULL 6 = null 2 = Array (size=7) 0 = float 1 Null 3 = String ' Market 3 Department ' (length=13) 4 = NULL 5 = NULL 6 = null \ = Array (si      ze=7) 0 = float 1 = null 2 = null 3 = String ' Market 4 Department ' (length=13) 4 = null    5 = null  6 = null 

Read the data in Excel into a two-dimensional array inside you do not need me to teach you, the following directly on the code.


  
   

程序运行结果为:

Array
(

[销售部] => Array ( [销售1区] => Array ( [0] => 销售1科室 [1] => 销售2科室 [2] => 销售3科室 [3] => 销售4科室 ) [销售2区] => Array ( [0] => 销售1科室 [1] => 销售2科室 [2] => 销售3科室 [3] => 销售4科室 ) )[市场部] => Array ( [市场1区] => Array ( [0] => 市场1科室 [1] => 市场2科室 [2] => 市场3科室 [3] => 市场4科室 ) [市场2区] => Array ( [0] => 市场1科室 [1] => 市场2科室 [2] => 市场3科室 [3] => 市场4科室 ) )

)

My approach is to mark Cat1,cat2,cat3 from the sorting column and then use a for loop in the background

It is right to get the data you want to format according to the adoption, but if you want to judge the operation of some data is more troublesome or may not be judged. For example, the three-level classification to determine that his parent exists is not to be judged can only be judged to add a subset of the need to add a new overall feeling the requirements of the format or need to be adjusted there are some problems I may be in the internal use requirements are not so stringent strict requirements or not in this format

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.