【发布时间】:2019-11-08 19:55:23
【问题描述】:
只有在返回的数组太长时才会在下面的代码中产生这个错误。使用短数组(我不知道具体有多少)不会发生。
$phone_numbers = array();
if(!empty($_POST['phone_numbers']))
$phone_numbers = json_decode($_POST['phone_numbers']);
$phone_numbers_var = str_repeat('?,', count(json_decode($_POST['phone_numbers'])) - 1) . '?'; // <-- error line
count()参数有限制吗?
【问题讨论】:
-
这是一个 PHP 问题吗?
-
为什么不在
$phone_numbers上使用count而不是json_decode两次?不,count没有限制 -
@dWinder 两种方法都试过了,错误依旧
-
除非它是双重编码的,否则无论数组大小如何,第二次解码都将返回 null。