-1
我在php中以關聯數組格式輸出以下twitter數據輸出,如何將此數據插入到mysql數據庫表中。請建議任何方式來做到這一點。插入關聯數組數據到mysql
Array (
[created_at] => Fri, 02 Nov 2012 18:15:57 +0000
[from_user] => VolksblattNews
[from_user_id] => 828753642
[from_user_id_str] => 828753642
[from_user_name] => Volksblatt News
[geo] => [id] => 2.6443066310356E+17
[id_str] => 264430663103557632
[iso_language_code] => de
[metadata] => Array ([result_type] => recent)
[profile_image_url] => http://a0.twimg.com/profile_images/2619216207/VB_48x48_reasonably_small_normal.gif
[profile_image_url_https] => https://si0.twimg.com/profile_images/2619216207/VB_48x48_reasonably_small_normal.gif
[source] => <a Google</a> => Bundesrat Burkhalter verstärkt Schweizer Beziehungen zu Burma: RANGUN - Didier Burkhalter hat… http://t.co/BF3aX2bY
[to_user] =>
[to_user_id] => 0
[to_user_id_str] => 0 [
to_user_name] =>)
我從下面的程序的輸出:
<?php
//a json string
$jsonstring='{
"created_at": "Fri, 02 Nov 2012 18:15:57 +0000",
"from_user": "VolksblattNews",
"from_user_id": 828753642,
"from_user_id_str": "828753642",
"from_user_name": "Volksblatt News",
"geo": null,
"id": 264430663103557632,
"id_str": "264430663103557632",
"iso_language_code": "de",
"metadata": {
"result_type": "recent"
},
"profile_image_url": "http://a0.twimg.com/profile_images/2619216207/VB_48x48_reasonably_small_normal.gif",
"profile_image_url_https": "https://si0.twimg.com/profile_images/2619216207/VB_48x48_reasonably_small_normal.gif",
"source": "<a href="http://www.google.com/">Google</a>",
"text": "Bundesrat Burkhalter verst\u00e4rkt Schweizer Beziehungen zu Burma: RANGUN - Didier Burkhalter hat\u2026 http://t.co/BF3aX2bY",
"to_user": null,
"to_user_id": 0,
"to_user_id_str": "0",
"to_user_name": null
}';
$arrayvariable=json_decode($jsonstring,true);
print_r ($arrayvariable);
?>
問候
請..format您的全陣列,因爲我已經做了.... –
有哪一個接受了真棒解決方案。 http://stackoverflow.com/questions/1744168/how-to-write-a-good-php-database-insert-using-an-associative-array – mansoor
你知道關係數據庫或SQL語言是如何工作的嗎?真的很難從這裏的答案中告訴你想要什麼。數據是否有一個設置的模式,或者你想知道如何序列化數組? –