php - i want to array key and array value comma separated string -


i have array , want convert string.
try string php implode() function not desired result.
output want arraykey-arrayvalue,arraykey-arrayvalue,arraykey-arrayvalue , on long array limit end.

 array ( [1] => 1 [2] => 1 [3] => 1 )  $data = implode(",", $pdata);  //it creating string  $data=1,1,1;  // want below   $string=1-1,2-1,3-1;  

you gather key pair values inside array implode it:

foreach($array $k => $v) { $data[] = "$k-$v"; } echo implode(',', $data); 

Comments

Popular posts from this blog

php - Wordpress: Link a post to posts of another category manually -

delphi xe7 upload/download dropbox file using the rest client and show progress -

java - Get more than One value and display it -