# Create global dynamic array names from variables passed to a function

**URL:** <https://forum.kirupa.com/t/create-global-dynamic-array-names-from-variables-passed-to-a-function/231751>\
**Category:** programming\
**Created:** [July 7, 2007, 3:23pm UTC](https://forum.kirupa.com/t/create-global-dynamic-array-names-from-variables-passed-to-a-function/231751 "2007-07-07T15:23:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nemoBejingler](https://avatars.discourse-cdn.com/v4/letter/n/ecae2f/32.png) [@nemoBejingler](https://forum.kirupa.com/u/nemoBejingler)\
**Post date:** [July 7, 2007, 3:23pm UTC](https://forum.kirupa.com/t/create-global-dynamic-array-names-from-variables-passed-to-a-function/231751/1 "2007-07-07T15:23:55Z")

</div>

Here’s an example of what I’m looking for:

```php
function randomEvent($var){
	global ${$var.'_edit'};
	${$var.'_edit'} = array( "Key1" => 1, "Key2" => 2, "Key3" => 3);
}

randomEvent($apple);
echo $apple_edit["Key1"];

```

Basically I want to create a global array from within a function, but give it a dynamic name based off of variables passed to the function from the initial call. Any help is greatly appreciated. Thx.
