-1

I have an array like this:

$Array = [
       [1, 33, 55, 18],
       [8, 9, 12, 67],
       [3, 33, 76, 88],
  ];

And I want add ; to output like this:

1, 33, 55, 18; 
8, 9, 12, 67; 
3, 33, 76, 88

Anyone know how to do this?

1

1 Answer 1

2

Use array map to achieve this

$temp = array_map(function($item){
    return implode(", ", $item);
}, $Array);
foreach($temp as $v){
    // implode with ';' and \n for line break
    // you can use "<br/>" if you are using web.
    echo $v.";\n"; 
}

Demo.

One looper:

foreach($Array as $v){
    echo implode(", ",$v).";\n";
}

Demo.

Output

1, 33, 55, 18;
8, 9, 12, 67;
3, 33, 76, 88;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.