I am doing a small calculator, that has randomly selected sequence of 3 chars (-
, /
and \
).
How can I combine my three arrays into one? I'm using array_merge
, but it creates an array that nests 3 arrays in it. How can I make this array one-dimensional?
My code (feedback welcome):
$_SESSION["sekvenssi"] = 15; //sekvenssi means "sequence" in Finnish.
$maara1 = rand(1, $sekvenssi/2); //Maara means "amount"
$maara2 = rand(1, $sekvenssi/2);
$kenot = array_fill(0, $maara1, "/");
$vastakenot = array_fill(count($kenot), $maara2, "\\");
$tayte = array_fill(
count($kenot)+count($vastakenot),
$_SESSION["sekvenssi"]-$maara1-$maara2,
"-"
);
$kaava = array_merge(array($tayte), array($kenot), array($vastakenot));
shuffle($kaava);
print "<p style='font-family: Courier;font-size: 18px;'>";
foreach ($kaava as $komponentit) {
print $komponentit;
}
print "</p>";
So this outputs "ArrayArrayArray", but I want it to produce one array with only one level (now it has 2 levels and thus cannot be printed).