Created
December 29, 2012 19:15
-
-
Save macik/4408758 to your computer and use it in GitHub Desktop.
// changes all array keys to keys with prefix
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 | |
$a = array('a1'=>'1','a2'=>2); | |
// changes all array keys to keys with prefix | |
$prefix = 'page_'; | |
$a = array_combine(explode(',', $prefix.implode(','.$prefix, array_keys($a))), array_values($a)); | |
print_r($a); | |
/* | |
Array | |
( | |
[page_a1] => 1 | |
[page_a2] => 2 | |
) | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment