Skip to content

Instantly share code, notes, and snippets.

@noginn

noginn/array_map.php

Created Dec 28, 2012
Embed
What would you like to do?
Using array_map with array_keys
<?php
$headers = array(
'X-PAYPAL-APPLICATION-ID' => 'APP-1234567890',
'X-PAYPAL-REQUEST-DATA-FORMAT' => 'NV',
'X-PAYPAL-RESPONSE-DATA-FORMAT' => 'NV'
);
$headerStrings = array_map(function ($key, $value) {
return $key . ': ' . $value;
}, array_keys($headers), $headers);
// $headerStrings => array(
// 'X-PAYPAL-APPLICATION-ID: APP-1234567890',
// 'X-PAYPAL-REQUEST-DATA-FORMAT: NV',
// 'X-PAYPAL-RESPONSE-DATA-FORMAT: NV'
// )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.