Link to home
Start Free TrialLog in
Avatar of Alex Lord
Alex Lord

asked on

implode displays array content as array array instead of values

 $trackedTreadIDs[] = array(
              'id' =>$getThreadIds['id']
            );

Open in new window


    
return implode(',', $trackedTreadIDs) ;

Open in new window



output  = testGM: "Array,Array"

it suspose to be two ids but displays array array ?
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

$trackedTreadIDs[] = array( 'id' =>$getThreadIds['id']  );
                ^^

Open in new window

You are assigning an array to an array. Did you want this
$trackedTreadIDs = array(
              'id' =>$getThreadIds['id']
            );

Open in new window

Or this
$trackedTreadIDs[] = $getThreadIds['id'];

Open in new window

I am guessing the latter - it is the only one that makes sense to use with implode.
implode() will implode a simple array, but it looks like you've got an array of arrays. Can't tell what $getThreadIds['id'] is from your code, so you might want to show us more info. That may well also be an array ??
Avatar of Alex Lord
Alex Lord

ASKER

not really no, im just trying to get two ids in a single array. than implode it
How about:

$result = implode(',', $getThreadIds['id']);
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial