我的代码中有这样一行:
list($user_id, $name, $limit, $remaining, $reset) = explode('|', $user);
最后 3 个参数可能存在也可能不存在。如果数组小于预期,是否有类似于列表的函数会自动忽略那些最后的参数?
最佳答案
list($user_id, $name, $limit, $remaining, $reset)
= array_pad(explode('|', $user), 5, null);
关于php - PHP 列表函数的可选参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15365392/