FANDOM


Arrays Example 1 Edit

$var[0] = "Hello";
$var[1] = " ";
$var[2] = "world";
$var[3] = "!";

for(%i=0;%i<4;%i++)
   %str = %str @ $var[%i];

echo(%str);

Arrays1

Arrays Example 2 Edit

$var[0] = "The horse eats";
$var[1] = "Hay";
$var[2] = "Saltlick";
$var[3] = "Cranberry Juice";

for(%i=0;%i<4;%i++)
   %str = %str SPC $var[%i];

echo(%str);

Arrays2

Find maximum and minimum values in an array Edit

for(%i=0;%i<9;%i++)
    $var[%i]=%i;

$londx = 0;
$hindx = 0;

for (%j = 1; %j <=9; %j++)
{
    if ($var[%j] < $var[$londx])
	$londx = %j;

    if ($var[%j] > $var[$hindx])
	$hindx = %j;
}

echo("The smallest element is ", $var[$londx]);
echo("The greatest element is ", $var[$hindx]);

Arrays3

Two dimensional arrays Edit

This will create an array of 16 (4x4) zeros.

for (%i = 1; %i <=4; %i++)
    for (%j = 0; %j <=4; %j++)
    {
	$var[%i+%j]=0;
	echo(" ",$var[%i+%j]);
    }


Three dimensional arrays Edit

Creates an array of 27 (3x3x3) zeros.

for (%i = 1; %i <=3; %i++)
    for (%j = 1; %j <=3; %j++)
	for (%k = 1; %k <=3; %k++)
	{
	    $var[%i+%j+%k]=0;
	    echo(" ",$var[%i+%j+%k]);
	}

See Also Edit

Scripts

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.