我在 php 中以关联数组格式输出了以下 twitter 数据,如何将这些数据插入到 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);
?>
问候