0

我有一个 URL 数组,我在 PHP 端迭代后保存在数据库中。我用 Ajax 发送数组并用 PHP 保存它。

通过 Ajax 发送数据

linksString=http://localhost/phpmyadmin/index.php?db=testdb&token=42d0dde57469a9aa4b6a2f7e0741,
http://localhost/phpmyadmin/index.php?db=testdb&token=98604a9aa4b6a2f7e0741,
http://localhost/phpmyadmin/index.php?db=testdb&token=9864dde57469a9aa4b6a2f7e0741,
http://localhost/phpmyadmin/index.php?db=testdb&token=986042d0dde57469a9aa4b6a2f7e0741,
http://localhost/phpmyadmin/index.php?db=testdb&token=986042d0dde57469a9a23&q=save 

未获取 $linksPieces 中的所有值,仅获取一个值

但是我没有在 PHP 端得到所有这些字符串;只获取第一个逗号(,)之前的第一个子字符串。IE

http://localhost/phpmyadmin/index.php?db=testdb&token=42d0dde57469a9aa4b6a2f7e0741

PHP

$linksPieces = array();
$links =  $_POST['linksString'];
$linksPieces = explode(",", $links);
foreach($linksPieces as $link)
{
   //operation
}   

我需要在 PHP 端获取数组中的所有字符串。

如果我发送这些没有任何 = 的 url,那么工作正常。

http://in.yahoo.com/ 

http://www.hotmail.com/

http://www.google.com/

http://www.blah.com/

http://www.blah1.com/
4

1 回答 1

1

您可以在发送此字符串之前尝试encodeURIComponent()在 Javascript 中使用urldecode(),在使用此字符串之前在 PHP 中使用。

于 2013-03-09T10:59:30.373 回答