1,"PHP"=>2,"Nginx">
时间:2021-07-01 10:21:17 帮助过:194人阅读
求提取这些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 );
查询分割循环入数组的笨办法除外. 谢谢
$a1 = array('C++','PHP','CSS');
$a2 = array('Nginx','PHP','API');
$merged = array_merge($a1,$a2);
$result = array_count_values($merged);
echo '';
print_r($result);
exit;
output:
Array
(
[C++] => 1
[PHP] => 2
[CSS] => 1
[Nginx] => 1
[API] => 1
)
晕了,为毛关掉问题啊. 也许还有更好的办法处理lz的大数据啊... 真无语