找到相同的值時,執行操作我在PHP兩種締合數組,其定義如下:在兩個PHP數組
$this_week[] = array(
"top_song_id" => $row["view_song_id"],
"top_place" => $i,
"top_move" => "0",
"top_last" => $i,
"top_peak" => $i,
"top_rating" => get_song_rating_by_id($row["view_song_id"]),
"top_views" => $row["view_sum"],
"top_start" => $monday,
"top_end" => $sunday
);
和
$last_week[] = array(
"top_song_id" => $row["view_song_id"],
"top_place" => get_song_place_by_id($row["view_song_id"]),
"top_move" => "0",
"top_last" => get_song_last_by_id($row["view_song_id"]),
"top_peak" => get_song_peak_by_id($row["view_song_id"]),
"top_rating" => get_song_rating_by_id($row["view_song_id"]),
"top_views" => $row["view_sum"],
"top_start" => $prev_monday,
"top_end" => $prev_sunday
);
現在,這裏是我的問題:如何能如果在一個數組中有任何歌曲ID可以在另一個數組中找到,我將遍歷這兩個數組並執行一個操作?
for()循環不起作用,因爲兩個數組可能有共同的歌曲,但不在同一個數組索引上。
任何幫助表示讚賞。