1, "PHP"=>2, "Nginx"=>1, "CSS"=>1, "API"=>1 ); 查询分割..."/> 1, "PHP"=>2, "Nginx"=>1, "CSS"=>1, "API"=>1 ); 查询分割...">
Rumah >pembangunan bahagian belakang >tutorial php >MYSQL 标签字段归类提取
有表 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;
output:
<code>Array ( [C++] => 1 [PHP] => 2 [CSS] => 1 [Nginx] => 1 [API] => 1 ) </code>
晕了,为毛关掉问题啊. 也许还有更好的办法处理lz的大数据啊... 真无语