Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.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
Php 无法将数组添加到数组内部_Php_Arrays - Fatal编程技术网

Php 无法将数组添加到数组内部

Php 无法将数组添加到数组内部,php,arrays,Php,Arrays,原件: $mesajData["msgBaslik"]="DEMO"; $mesajData["msgData"][]=array( "tel"=>["5533038893","5544723385"], "msg"=>"Api Test" ); 我想在“tel”索引中添加一个数组,但还没有成功 只有成功才能尝试: $mesajData1["msgData"][]=array( "tel"=>[$to[0],$t

原件:

$mesajData["msgBaslik"]="DEMO";
    $mesajData["msgData"][]=array(
        "tel"=>["5533038893","5544723385"],
        "msg"=>"Api Test"
    );
我想在“tel”索引中添加一个数组,但还没有成功

只有成功才能尝试:

$mesajData1["msgData"][]=array(
        "tel"=>[$to[0],$to[1]],
        "msg"=>"Api Test"
    );
但有时它在数组中有100多个值,不能这样做。

多亏了| Ghost|

//$to -> Array with numbers
    $mesajData["msgBaslik"]="DEMO";
        $mesajData["msgData"][]=array(
            "tel"=>"",
            "msg"=>"Api Test"
        );
        for($x=0;$x<count($to);$x++){
            $mesajData['msgData'][0]['tel'][]="$to[$x]";
        }
/$to->带数字的数组
$mesajData[“msgBaslik”]=“演示”;
$mesajData[“msgData”][]=数组(
“电话”=>”,
“msg”=>“Api测试”
);

对于($x=0;$x,只需不断地将其放入该特定索引中:
$mesajData['msgData'][0]['tel][]='which value this';