Search code examples
phparraysvar-dump

Display value of Array


I have this function :

$array = $um_followers->api->following( $currentid );

If I tried a var_dump :

var_dump($um_followers->api->following( $currentid ));

This is the result :

array(2) { [0]=> array(1) { ["user_id1"]=> string(1) "1" } [1]=> array(1) { ["user_id1"]=> string(2) "44" } }

1) I want to display the data 1 and 44 in the same line

2) I want to display the data 1 and 44 in the same line with a coma


Solution

  • you can do

    echo implode(' ', array_column( $array,'user_id1')); 
    echo implode(', ', array_column( $array,'user_id1')); // with comma