PHP로 코드를 작성하여 모든 미디어 게시물에 사용한 해시 태그를 수집하고 해시 태그를 사용한 게시물 수와 얼마나 많은 게시물을 좋아하는지 확인합니다. 해시 태그가 총 수신되었습니다.PHP는 다중 배열을 다차원 배열로 결합합니다.
내 데이터베이스의 모든 미디어 게시물을 수집했으며 이제이 정보를 내보낼 수 있습니다. 나는 다음과 같은 기능을 사용하여 이러한 해시 태그를 분리 할 수 있어요
Array
(
[0] => Array
(
[id] => 1
[caption] => #londra #london #london_only #toplondonphoto #visitlondon #timeoutlondon #londres #london4all #thisislondon #mysecretlondon #awesomepix #passionpassport #shootermag #discoverearth #moodygrams #agameoftones #neverstopexploring #beautifuldestinations #artofvisuals #roamtheplanet #jaw_dropping_shots #fantastic_earth #visualsoflife #bdteam #nakedplanet #ourplanetdaily #earthfocus #awesome_earthpix #exploretocreate #londoneye
[likesCount] => 522
)
[1] => Array
(
[id] => 2
[caption] => #londra #london #london_only #toplondonphoto #visitlondon #timeoutlondon #londres #london4all #thisislondon #mysecretlondon #awesomepix #passionpassport #shootermag #discoverearth #moodygrams #agameoftones #neverstopexploring #beautifuldestinations #artofvisuals #roamtheplanet #jaw_dropping_shots #fantastic_earth #visualsoflife #bdteam #nakedplanet #ourplanetdaily #earthfocus #awesome_earthpix #harrods #LDN4ALL_One4All
[likesCount] => 1412
)
)
: 여기에 출력되는 다차원 배열의 예입니다
function getHashtags($string) {
$hashtags= FALSE;
preg_match_all("/(#\w+)/u", $string, $matches);
if ($matches) {
$hashtagsArray = array_count_values($matches[0]);
$hashtags = array_keys($hashtagsArray);
}
return $hashtags;
}
는 지금은 각각의 다차원 배열을 만들려면 해시 태그는 다음과 같아야합니다.
Array
(
[0] => Array
(
[hash] => #londra
[times_used] => 2
[total_likes] => 153
)
[1] => Array
(
[hash] => #london
[times_used] => 12
[total_likes] => 195
)
)
저는 이것을 아주 잘 알고 있으며이를 달성하는 방법을 모르겠습니다. 도움과 제안을 부탁드립니다!
어떻게 당신이 좋아하는 각 해시 태그에 대한 계산 계산합니까? – sidyll
계산하기는 어렵지만 has 태그가 사용 된 게시물의 전체 좋아요 수를 요약 한 다음 사용 된 게시물 수로 나눕니다. –