$objects = array(array('lon' => 1, 'lat' => 2), ..., ...);
$cluster = array();
$levels = 10;
$firstRectWidth = 0.01; //самый маленький "квадрат" будет 1111 на 1111
for ($i = 0; $i < count($objects); $i++)
{
$obj = $objects[$i];
for ($level = 1; $level <= $levels; $level++)
{
$lon_index = ($obj->lon) / ($firstRectWidth * (2 ^ $level)); // не помню как степень в php
$lat_index = ($obj->lat) / ($firstRectWidth * (2 ^ $level)); // не помню как степень в php
$cluster[$level][$lon_index . "-" . $lat_index][] = $i;
}
}
// использование
$zoom = 1..10;
echo "кластеров ".(count($cluster[$zoom]))."<br >";
foreach ($cluster[$zoom] as $key => $value)
{
echo "область ".$key."<br >";
echo "кол-во элеметнов ". (count($value));
}
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
...
<head>
<script>
$.post( "test.php", { name: "John", time: "2pm" } , function(data) {
//выполнится после запроса и в data будет лежать то, что выведет скрипт test.php в output
});
</script>
<script>
$.post( "test.php", 'key1=value1&key2=value2' , function(data) {
//выполнится после запроса и в data будет лежать то, что выведет скрипт test.php в output. в этом случае в php будет доступно $_POST['key1']
} );
</script>
fucntion getFileNames($root)
{
$out = array();
$files = scandir($root);
for ($i = 0; $i < count($files); $i++)
{
$name = $files[$i];
if ($name == "." || $name == "..")
{
continue;
}
if (is_dir($root . "/" . $name))
{
$out = array_merge($out, getFileNames($root . "/" . $name));
}
else
{
$out[] = $name;
}
}
return $out;
}
function convertArray($array, $path)
{
$result = array();
for ($i = 0; $i < count($array); $i++)
{
$result[] = $path . "/" . $array[$i];
}
return $result;
}
fucntion getFileNames($root)
{
$out = array();
$files = convertArray(scandir($root), $root);
while (count($files))
{
$path = array_shift($files);
if (basename($path) == "." || basename($path) == "..")
{
continue;
}
if (is_dir($path))
{
$files = array_merge($files, convertArray(scandir($path), $path);)
}
else
{
$out[] = basename($name);
}
}
return $out;
}
$files = ... // получить список файлов в массив
$files = array("fiel1.txt", "fiel3.txt", "file4.txt"); // например
$current_page = 1; //например
$limit = 2;
for ($i = $current_page * $limit; $i < count($files) && $i < ($current_page + 1) * $limit; $i++)
{
echo $files[$i];
}
file4.txt
$sql = 'SELECT * FROM message WHERE (canal="hibye" OR canal="byehi") AND private="1"';
$message = ... // выполнить запрос
if ("hibye" == $message["canal"])
{
//...
header('Location: page1.php');
die();
}
else if ("byehi" == $message["canal"])
{
//...
header('Location: page2.php');
die();
}
<?php
$data = array(
array(
'title' => 'Arduino #1',
'id' => 1,
'image' => 'http://www.casemods.ru/templates/images/texts/3_4119479.jpg',
'top' => 200,
'left' => 300,
'width' => 800,
'height' => 760,
'points' => array(
'id' => 1,
'objectId' => 1,
'top' => 300,
'left' => 500,
'tip' => 500,
),
),
array(
'title' => 'Arduino #2',
'id' => 2,
'image' => 'img/objects/arduino.png',
'top' => 200,
'left' => 300,
'width' => 800,
'height' => 760,
'points' => array(
'id' => 1,
'objectId' => 2,
'top' => 300,
'left' => 500,
'tip' => 500,
),
)
);
?>
<script type="text/javascript">
var data = <?php echo json_encode($data); ?>;
console.log(data[0]["title"]);
</script>
if (isset($r))
{
echo "Текст";
}
if ($r == true)
{
echo "Текст";
}
if ($r === true)
{
echo "Текст";
}