Created
August 5, 2011 23:37
-
-
Save egfx/7cc8d3f8b91c4a5efd9b to your computer and use it in GitHub Desktop.
Replace a key in an associative array, preserving the original order of keys and elements:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('array_combine')) { // ONLY EXISTS IN PHP5 | |
function array_combine($keys, $values) { | |
if (count($keys) != count($values)) { | |
return false; } | |
foreach($keys as $key) { $array[$key] = array_shift($values); } | |
return $array; } | |
} // END IF FUNCTION EXISTS | |
$keys = array_keys($array); | |
$values = array_values($array); | |
foreach ($keys as $k => $v) { | |
if ($v == "MANAGEMENT FEE CHARGE") { $keys[$k] = "MANAGEMENT FEES"; } | |
} | |
$array = array_combine($keys, $values); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment