Here is my problem.
I have created two bunny’s with character and want to display them, als with PHP.
For the two bunny’s I created a multidimensional array:
$bunnys = array(
array( //$bunny
array(' ', ' ', '(', ')', ' ', '(', ')', ' ', ' '), //$row en in de array is $piece
array(' ', ' ', '(', 'o', '.', 'o', ')', ' ', ' '),
array(''', '(', '"', ')', ' ', '(', '"', ')', '''),
),
array(
array(' ', ' ', '(', ')', ' ', '(', ')', ' ', ' '),
array(' ', ' ', '(', '>', '.', '<', ')', ' ', ' '),
array(''', '(', '"', ')', ' ', '(', '"', ')', '''),
),
);
Then I want to echo the bunny’s using the foreach loop:
echo "<pre>";
foreach($bunnys as $bunny)
{foreach ($bunny as $row)
{foreach ($row as $piece)
echo "$piece";
echo "<br>";
}
}
echo "</pre>";
Actual result
The problem is, is that the bunny’s are standing underneath eachother, like this:
() ()
(o.o)
‘(") (")’
() ()
(>.<)
‘(") (")’
Desired result
But what I want, is that the bunny’s standing next to each other, like this:
() () () ()
(o.o) (>.<)
‘(") (")”(") (")’
I already tried to delete the echo "<br>";
, but then the result is that there are six lines.
Anybody havind an idea what I am doing wrong?
2
Answers
Try array_merge — Merge one or more arrays
https://www.php.net/manual/en/function.array-merge.php
output
see in action
https://onlinegdb.com/yP0-SxazPR