function sample($type) { $type = intval($type); switch ($type) { case 1: if (($handle = fopen("./data/test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { debug_arr($data); } fclose($handle); } break; default: $data = array(); } }
function points() { $points = array(); for ($i = 0; $i < 12; $i++) { $points[] = array('x' => rand(10, 200), 'y' => rand(10, 200)); } $distance = array(); foreach ($points as $index => $point) { foreach ($points as $idx => $pt) { if ($idx != $index && empty($distance["{$idx}-{$index}"])) { $distance_calc = pow($point['x'] - $pt['x'], 2) + pow($point['y'] - $pt['y'], 2); $distance_calc = sqrt($distance_calc); // echo "<div>({$point['x']} - {$pt['x']})^2 + ({$point['y']} - {$pt['y']})^2 = {$distance_calc}</div>"; $distance["{$index}-{$idx}"] = round($distance_calc, 3); } } } asort($distance); debug_arr($points); debug_arr($distance); // echo json_indent($points); }
function traceAll() { debug_arr($this->nodes); }