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 ) ) 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'); 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 Link to comment https://forums.phpfreaks.com/topic/225537-edit-array-value/#findComment-1164622 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.