Quantcast
Channel: Fastest way to implode an associative array with keys - Stack Overflow
Viewing all articles
Browse latest Browse all 14

Answer by Unicco for Fastest way to implode an associative array with keys

$
0
0

Use array_walk for this.

$arr = ["key"  => "value","key2" => "value2",];array_walk($arr, function(&$value, $key) {    $value = "{$key}: {$value}";});implode("<br/>", $arr)

Result

key: value<br/>key2: value2<br/>

Viewing all articles
Browse latest Browse all 14

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>