knowram Posted May 10, 2007 Share Posted May 10, 2007 Is it possible to specify the key when using array_push? Something like this array_push($Company, $Office => $Office_Location); Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/50797-simple-array_push-question/ Share on other sites More sharing options...
effigy Posted May 10, 2007 Share Posted May 10, 2007 No, but there are some custom functions in the User Contributed Notes of array_push for this. Quote Link to comment https://forums.phpfreaks.com/topic/50797-simple-array_push-question/#findComment-249783 Share on other sites More sharing options...
knowram Posted May 10, 2007 Author Share Posted May 10, 2007 Thanks i just found them. here is the one that I am using function array_push_associative(&$arr) { $args = func_get_args(); array_unshift($args); // remove &$arr argument foreach ($args as $arg) { if (is_array($arg)) { foreach ($arg as $key => $value) { $arr[$key] = $value; $ret++; } } } return $ret; } Quote Link to comment https://forums.phpfreaks.com/topic/50797-simple-array_push-question/#findComment-249792 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.