2017 © Pedro Peláez
 

library array-circle-fetch

Fetch elements from array in a circle pattern

image

jonasof/array-circle-fetch

Fetch elements from array in a circle pattern

  • Friday, October 28, 2016
  • by jonasof
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Array Circle Fetch

Fetch elements from array in a circle pattern., (*1)

Pass the following table:, (*2)

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25

Its like the following array:, (*3)

$count = 1;

$array = [];
for($y = 0; $y < 5; $y++) {
  $array = [$y];
  for($x = $x < 5; $x++) {
    $array[$y][$x] = $count;
    $count++;
  }
}

So you specify a point by keys and choice a radius to get. Lets to get the point ["x" => 3, "y" => 2], and a 3 elements radius., (*4)

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
$circlefetch = new ArrayCircleFetch($array);
$result = $circlefetch->get(["x" => 3, "y"=> 2], 3);

Will get:, (*5)

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25

In a one dimension array:, (*6)

[2,3,4,6,7,8,9,10,12,13,14,18]., (*7)

TODO

  • build a small square in 2*radious size to get more performance.

The Versions

28/10 2016

dev-master

9999999-dev https://github.com/jonasof/array-circle-fetch/

Fetch elements from array in a circle pattern

  Sources   Download

MIT

The Requires

  • php >=5.4

 

array geographic