2012-02-23 15 views
-3

我的HTML數據,如

Array([postedMsg] => <font color="blue">Blogger Wallpost</font> 
     [nbsp;<div_dir] => "ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-JrRECIxhi4s/TzpAs4lmgnI/AAAAAAAAAD4/KWcPpfXEGtU/s1600/800px-Cooked_Poha.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;">image</a></div><div class="separator" style="clear: both; text-align: center;">Happy Blogger Wallpost</div><br></div><div class="blogger-post-footer">image src</div> 
    ) 

我嘗試使用類似的代碼

foreach($htmlpostedMsg AS $key => $value) 
    { 
    $htmlpostedMsg[$key] = $value; 
    } 
    print_r($htmlpostedMsg[$key]); 
插入MySQL數據庫的$ _ POST整個價值

它打印只喜歡

\"ltr\" style=\"text-align: left;\" trbidi=\"on\"><div class=\"separator\" style=\"clear: both; text-align: center;\"></div><div class=\"separator\" style=\"clear: both; text-align: center;\"></div><div class=\"separator\" style=\"clear: both; text-align: center;\"></div><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"http://4.bp.blogspot.com/-JrRECIxhi4s/TzpAs4lmgnI/AAAAAAAAAD4/KWcPpfXEGtU/s1600/800px-Cooked_Poha.jpg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\">image src</a></div><div class=\"separator\" style=\"clear: both; text-align: center;\">Happy Blogger Wallpost</div><br></div><div class=\"blogger-post-footer\">image src</div>\n 
+0

請正確格式化您的問題。目前這樣一團糟,我甚至不知道從哪裏開始編輯它。 – JJJ 2012-02-23 08:41:48

+0

請格式化該代碼,以便我們有機會了解它。 – 2012-02-23 08:41:57

+0

我試圖編輯您的文章,但無法弄清楚:所有這些樣式都是原始代碼中的,還是來自您複製的地方? (也許是一個格式化的HTML頁面)。請重新格式化您的代碼,因爲目前難以辨認 – 2012-02-23 08:43:43

回答

-2

最後一部分可以在$_POSTserialize,然後存儲在MySQL表。

+2

這回答標題,但不是問題;-)第一個問題 – 2012-02-23 08:45:03

+0

搞砸了。所以我已經回答了標題。任何標題應該與問題有關。 :) – san 2012-02-23 12:49:34

2

您可以簡單地使用提取方法從POST值

獲得關聯數組假設你有後陣列比如$ _ POST [ '名'],$ _ POST [ '電子郵件']

 extract($_POST); 
     echo $name;// 'name you entered'; 
     echo $email;// 'email you entered'; 
+0

如果你不知道你在做什麼,這是一個相當危險的方法。用戶可以將任何變量插入到他們想要的腳本中。此外,它所做的只是保存幾個按鍵,因此您不必編寫完整的「$ _POST ['name']」。 – JJJ 2012-02-23 13:30:21

+0

這是http://php.net/manual/en/function.import-request-variables.php內置函數 – Sethunath 2012-04-09 11:06:21