MYSQL Label Field Collation extraction

Source: Internet
Author: User
There are table tbl_contents; field tag, content such as
 
"C++,php,css"
"Nginx,php,api"

The good way to extract these tags and count the number of occurrences to the array (PHP implementation) results are as follows

Array ("C + +" =>1, "PHP" =>2, "Nginx" =>1, "CSS" =>1, "API" =>1);

Except for the dumb way of querying the array in a split loop. Thank you

Reply content:

There are table tbl_contents; field tag, content such as
 
"C++,php,css"
"Nginx,php,api"

The good way to extract these tags and count the number of occurrences to the array (PHP implementation) results are as follows

Array ("C + +" =>1, "PHP" =>2, "Nginx" =>1, "CSS" =>1, "API" =>1);

Except for the dumb way of querying the array in a split loop. Thank you

  $a 1 = array (' C + + ', ' php ', ' CSS '), $a 2 = array (' Nginx ', ' php ', ' API '); $merged = Array_merge ($a 1, $a 2); $result = Array_count_values ($merged); Echo '  
 ';p rint_r ($result); exit;  

Output:

  Array ([C + +] + 1 [PHP] + 2 [CSS] + 1 [Nginx] = 1 [API] + 1)  

Halo, turn off the problem for Mao. Maybe there is a better way to deal with the LZ Big data Ah ... Really no words

  • 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.