jonasof / array-circle-fetch
以环形模式从数组中获取元素
dev-master
2016-10-28 02:10 UTC
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2024-09-14 18:47:33 UTC
README
以环形模式从数组中获取元素。
传递以下表格
就像以下数组
$count = 1; $array = []; for($y = 0; $y < 5; $y++) { $array = [$y]; for($x = $x < 5; $x++) { $array[$y][$x] = $count; $count++; } }
所以你通过键指定一个点,选择一个半径来获取。让我们获取点 ["x" => 3, "y" => 2],以及一个3个元素的半径。
$circlefetch = new ArrayCircleFetch($array); $result = $circlefetch->get(["x" => 3, "y"=> 2], 3);
将会获取
在一个一维数组中
[2,3,4,6,7,8,9,10,12,13,14,18].
待办事项
- 构建一个边长为2*半径的小正方形,以提高性能。