Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过ajax将数组发送到php_Php_Arrays_Ajax - Fatal编程技术网

通过ajax将数组发送到php

通过ajax将数组发送到php,php,arrays,ajax,Php,Arrays,Ajax,我正在通过ajax向PHP发送数组。如何从PHP获取数组 $('.send-image').on('click', function() { $.ajax({ type:"POST", url:"sendimages.php", data: { images: imgArr }, success: function(data) { console.log(dat

我正在通过ajax向PHP发送数组。如何从PHP获取数组

$('.send-image').on('click', function() {
    $.ajax({
        type:"POST",
        url:"sendimages.php",
        data: {
            images: imgArr
        },
        success: function(data) {
            console.log(data);
        },
        error: function(e) {
            console.log(e);
        }
    });
});
我试过这个,但不起作用

$images = $_POST['imgArr'];
foreach($images as $d) {
    echo $d;
}
替换

$images = $_POST['imgArr'];

因为索引
图像
来自这里:

data: {
    images: imgArr
}

输出是什么?此外,var_dump($_POST['imgArr'])的输出是什么?这应该可以让你决定一个解决方案。让我们看看你如何设置
imgArr
这就是我的整个js-
data: {
    images: imgArr
}