1, "PHP"=>2, "Nginx"=>1, "CSS"=>1, "API"=>1 ); 查询分割..."/> 1, "PHP"=>2, "Nginx"=>1, "CSS"=>1, "API"=>1 ); 查询分割...">
Home > Backend Development > PHP Tutorial > MYSQL 标签字段归类提取

MYSQL 标签字段归类提取

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:50:18
Original
1173 people have browsed it

有表 tbl_contents; 字段 tag, 内容如
 
"C++,PHP,CSS"
"Nginx,PHP,API"

求提取这些Tag并统计出现次数到数组的好办法(PHP实现) 结果如

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

查询分割循环入数组的笨办法除外. 谢谢

回复内容:

有表 tbl_contents; 字段 tag, 内容如
 
"C++,PHP,CSS"
"Nginx,PHP,API"

求提取这些Tag并统计出现次数到数组的好办法(PHP实现) 结果如

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

查询分割循环入数组的笨办法除外. 谢谢

<code>$a1 = array('C++','PHP','CSS');
$a2 = array('Nginx','PHP','API');
$merged = array_merge($a1,$a2);
$result = array_count_values($merged);
echo '<pre class="brush:php;toolbar:false">';
print_r($result);
exit;
Copy after login

output:

<code>Array
(
    [C++] => 1
    [PHP] => 2
    [CSS] => 1
    [Nginx] => 1
    [API] => 1
)
</code>
Copy after login

晕了,为毛关掉问题啊. 也许还有更好的办法处理lz的大数据啊... 真无语

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template