1

This is my array

Array
(
[0] => Array
    (
        [0] => SC1MTTCS6J1WK
    )

[1] => Array
    (
        [0] => SC1MTTCSHJ1WK
    )
)

But when I try to implode them using

$in_text = implode(",", $myArray3);

I can't get the value instead I got this:

Array,Array

Please assist thank you.

LF00
  • 27,015
  • 29
  • 156
  • 295
Ku Syafiq
  • 63
  • 6
  • Kindly visit this link. https://stackoverflow.com/questions/16710800/implode-data-from-a-multi-dimensional-array – Noel B. Dec 05 '17 at 03:38

3 Answers3

2

Here is the simple code, try this

$in_text = implode(',',array_map('implode',$myArray3));
echo $in_text;
Muhammad Sadiq
  • 1,147
  • 11
  • 13
0

Try this code,

$in_text = '';
foreach ($myArray3 as $key=>$val){
    if(is_array($val)) {
        $in_text .= ($in_text != '' ? ',' : ''). implode(",", $val);;
    } else {
        $in_text .= ($in_text != '' ? ',' : ''). $val;
    }
}
echo $in_text;

PS: This will work upto two dimensional array.

Naga
  • 2,190
  • 3
  • 16
  • 21
0

You call implode on an array of array, which result the Array, Array. You can call like this,

implode(",", array_column($myArray3, 0));
LF00
  • 27,015
  • 29
  • 156
  • 295