我在类似的数组中有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]);
它只打印最后一部分像
'"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
您可以简单地使用extract方法从POST值中获取关联数组
假设您有类似$_post['name']、$_post'email']的post数组
extract($_POST);
echo $name;// 'name you entered';
echo $email;// 'email you entered';
您可以在$_POST
上进行序列化,然后存储在mysql表中。