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

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -