为什么Javascript数组不';在php中不会内爆吗?

为什么Javascript数组不';在php中不会内爆吗?,javascript,php,arrays,implode,Javascript,Php,Arrays,Implode,我实际上检查了这个数组var\u rls=['24','56'] var checked_rls = [] $("input[name='chk_cont[]']:checked").each(function () { checked_rls.push($(this).val()); }); 然后我尝试使用AJAX传递它 $.ajax(

我实际上检查了这个数组
var\u rls=['24','56']

            var checked_rls = []
            $("input[name='chk_cont[]']:checked").each(function ()
            {
                checked_rls.push($(this).val());
            });
然后我尝试使用AJAX传递它

  $.ajax(
            {
                type :"POST",
                url : "sale_ajax.php",
                data: 
                {
                    rls :  checked_rls,
                    rls_date : $("#rls_date").val()
                },
                success: function(msg)
                {
                    alert('saved successfully');

                },
                error: function()
                {
                    alert("Failure");
                }
            });
然后我在sale_ajax.php文件中收到了如下数组
$cont=$\u POST['rls']

            var checked_rls = []
            $("input[name='chk_cont[]']:checked").each(function ()
            {
                checked_rls.push($(this).val());
            });
现在的问题是,我可以在forEach函数中运行这个数组,但是当我尝试将这个数组内爆为字符串时,它只返回一个值

例如,在这个场景中,我通过了24,56,当我试图
内爆时(“,”,$cont)
;它只返回第一个值24:

var_dump($cont) output is
array(2){[0]=>string(2) "24" [1]=>string(2) "56"} 
php代码是:

if(isset($_POST['rls']))
    {
        $rls_date = $_POST['rls_date'];
        $cont = $_POST['rls'];
        $rls_cont_sold = implode(",",$cont);

         $rls_insert = mysql_query("INSERT INTO release_details (release_date, cont_sold_id) VALUES (STR_TO_DATE('$rls_date', '%d-%m-%Y'), '$rls_cont_sold')")or die(mysql_error());          
         $id = mysql_insert_id();

        foreach($cont as $val)
        {       
          $cont_sold_update = "UPDATE cont_sold SET release_details_id = '$id' WHERE cont_sold_id = '$val'";
          $insert = mysql_query($cont_sold_update)or die(mysql_error());         
        }
    }
而var_dump($_POST)是

在这种情况下究竟发生了什么?
谢谢

点击
chk\U计数事件的
元素中放入以下代码:-

$("input[name='chk_cont[]']").click(function(){         
          var checked_rls = [];
            $("input[name='chk_cont[]']:checked").each(function ()
            {
                checked_rls.push($(this).val());
            });
});

与其传递数组,不如传递字符串本身,这样可以减少步数

       var checked_rls = "";
        $("input[name='chk_cont[]']:checked").each(function ()
        {
            checked_rls += $(this).val()+",";
        });

检查
的位置\u rls
?若要为问题添加详细信息,请使用问题下的“编辑”链接,而不是注释。同时添加
php
代码。您的意思是,您的数据库中插入了24个代码?请尝试
var\u dump($rls\u cont\u sell)
查看它是否正确内爆,如果显示正确,则我认为问题在于
INSERT
queryname结果。只能保存第一个数字。内爆不工作尝试进行var_转储($_POST['rls']);您应该在两个值之间添加一些分隔符