- implode: documentation ( source)
- array_walk: documentation ( source)
- sprintf: documentation ( source)
<?php
$data = array(
'ordernumber' => '#ordernumber',
'transactionamount' => '#transactionamount',
);
array_walk($data, function(&$value, $key) {
$value = sprintf('%s|%s', $key, $value);
});
echo implode('|', $data);