I would need this matrix represented by a 2d field
JavaScript
x
Array
(
[0] => Array
(
[0] => .
[1] => .
[2] => .
[3] => .
)
[1] => Array
(
[0] => .
[1] => X
[2] => X
[3] => .
)
[2] => Array
(
[0] => .
[1] => X
[2] => X
[3] => .
)
)
on a string in the form.
‘…. n
.XX. n
.XX.n
….’
Thank you in advance for any advice.
Advertisement
Answer
Use array_map()
to call implode()
on each element to get an array of strings. Then implode that to get a single string separated by n
.
JavaScript
$result = implode('n', array_map('implode', $array));