public function getArray()
    {
        $arr = array();
        $arr[0] = 0;
        for ($teller = 1; $teller < 50; $teller++) {
            $arr[$teller] = $teller + $arr[$teller - 1];
        }
        return $arr;
    }
}
?>

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php 
$array = new ArrayGenerator();
print_r($array->getArray());
?>
    </body>
</html>
Exemplo n.º 2
0
<?php

require_once './classes/ArrayGenerator.php';
require_once './classes/ExportImportJSON.php';
$ArrayGenerator = new ArrayGenerator(5, 50);
$ExportImportJSON = new ExportImportJSON();
// Generate array data
$sharesArray = $ArrayGenerator->getArray();
$sharesCategories = $ArrayGenerator->getCategories();
// Save generated arrays to JSON file
/*$ExportImportJSON->setFileName('dataFirstCategories-v1.json')->setFileData($sharesCategoriesFirst)->export();
$ExportImportJSON->setFileName('dataFirst-v1.json')->setFileData($sharesArrayFirst)->export();*/
// Load generated arrays to JSON file
$sharesArray = $ExportImportJSON->setFileName('dataFirst-v1.json')->import()->getFileData();
$sharesCategories = $ExportImportJSON->setFileName('dataFirstCategories-v1.json')->import()->getFileData();
var_dump($sharesArray);
var_dump($sharesCategories);
$var2 = 1;
while ($var2 < 5000) {
    print $var1 . " " . $var2 . " ";
    $var1 += $var2;
    $var2 += $var1;
}
?>
        <h2>De fibonacci-code uit het grote antwoordenboek: </h2>
         <?php 
$oud = 0;
$nieuw = 1;
print $oud . " ";
while ($nieuw < 5000) {
    print $nieuw . " ";
    $vorigOud = $oud;
    $oud = $nieuw;
    $nieuw = $vorigOud + $oud;
}
?>
        
        <h2>De fibonacci reeks met een array</h2>
        <pre>
        <?php 
$arrgen = new ArrayGenerator();
print_r($arrgen->getArray());
?>
        </pre>
        
    </body>
</html>