Destramic Posted January 24, 2011 Share Posted January 24, 2011 hey guys i have an array but want to add "n." infront of each key value...example n.news_id, n.user_id etc...is there a simple way/function of doing it other than changing the values through a loop? Array ( [news] => Array ( [0] => news_id [1] => user_id [2] => news [3] => date [4] => time ) ) Quote Link to comment https://forums.phpfreaks.com/topic/225537-edit-array-value/ Share on other sites More sharing options...
bh Posted January 24, 2011 Share Posted January 24, 2011 Hi, try the array_walk_recursive function. Heres an example: $array = array('a' => 2, 'b' => array('c', 'd', 2, 3)); function modder(&$item, $key) { if (is_string($item)) $item = 'n.'.$item; } array_walk_recursive($array, 'modder'); Quote Link to comment https://forums.phpfreaks.com/topic/225537-edit-array-value/#findComment-1164601 Share on other sites More sharing options...
Destramic Posted January 24, 2011 Author Share Posted January 24, 2011 wow i think that is exactly what i want thanks for your reply...a just a quick on what do you call a column when add the alias infont of it eg. n.news_id...would it be called a column alias? thanks again Quote Link to comment https://forums.phpfreaks.com/topic/225537-edit-array-value/#findComment-1164622 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.