Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是一个简单的问题,但在这里搜索我发现了不同的变化,但并不是我真正需要的。所以:
假设我有一组数字:[1,4,5,7,9] 我需要的是一个倒数的结果集,最大为 10:[2,3,6,8,10]
$initialArray = array(1,4,5,7,9); $requiredRange = range(1,10); $invertedArray = array_diff($requiredRange,$initialArray);