EvaldasL
EvaldasL

Reputation: 105

PHP string implode: Invalid arguments passed in

$allProfiles = '';
foreach( array_merge( $profile, $otherProfiles )  as $all ):
    $allProfiles .= $all;
endforeach;

echo "Player all profiles: $allProfiles";

This prints for me Player all profiles: NameNameNameNameName, how can I implode by comma? When I make $allProfiles .= implode(",", $all); Then I got Invalid arguments passed in Thanks in advance

EDIT

Just changed $allProfiles .= $all; to $allProfiles[] = $all;

Then in echo used implode ..

Upvotes: 0

Views: 40

Answers (1)

Niklesh Raut
Niklesh Raut

Reputation: 34924

Make array like this

 $allProfiles = array();
 foreach( array_merge( $profile, $otherProfiles )  as $all ):
       $allProfiles[]= $all;
 endforeach;

echo "Player all profiles: ".implode(",",$allProfiles);

Upvotes: 2

Related Questions