@hecate0211 Are you trying to re-order the elements in the outer array? You could try array_reverse($arrays).
Oct 4, 2017
4
Level 1
PHP array output
i have an array like this
$arrays = array(array('a','b','c','d','e'), array(1,2,3,4,5));
and i want to show this array like this [['a','b','c','d','e'],[1,2,3,4,5]]
i have try using print_r and dd but it cant show up like that.. can u help me?
Level 15
Super duper answermagic based on literal interpretation of question:
echo '[';
foreach ($arrays as $v) {
foreach ($v as $x) {
echo '[' . $x . ']';
}
if (! next($arrays) === false) {
echo ',';
}
}
echo ']';
In all seriousness, could you provide some more detail on what you are trying to accomplish? Where are you wanting to print your array formatted that way? For what purpose?
Please or to participate in this conversation.