ID我有一個用戶表如下獲取陣列
TABLE USERS
user_id user_name user_rooms
1 PAUL serialized and base64_encoded data (1, 2, 4, 5, 6, 7, 8, 9, 10)
2 JOHNL serialized and base64_encoded data (1, 2, 3)
3 MARK serialized and base64_encoded data (3)
我需要創建從該表數組USER_ID至極訪問的房間,在此示例中到室溫3:
Array ([0] => 2, [1] => 3)
查詢(即將切換至的mysqli)爲:
$result = mysql_query("SELECT user_id, user_rooms FROM table_users");
$rooms = Array();
while ($row = mysql_fetch_assoc($result)) {
$user_room[] = unserialize(base64_decode($row['user_rooms']));
}
$rooms
返回房間數組,我想獲得與user_id數組
任何幫助嗎?
爲什麼'user_rooms'存儲呀? –
切換到'mysqli'是個好主意,但更好的是轉向[PDO](http://php.net/manual/en/book.pdo.php)。 – tadman
你究竟在這裏問什麼?難道你不能只是''user_id [] = $ row ['user_id']',就像你使用'user_rooms'一樣嗎? –