php - function to set var if it key exists in array, otherwise set to default
<p>So I've got a class that I'd like to have it just set defaults if they're not passed in. For example, I can pass it an array called $options.</p>

<pre><code>function new_score($options)
{

}
</code></pre>

<p>Then I'd like to have a different function that I can set a var to a default if a key with that var's name doesn't exist in the $options array;</p>

<p>The function definition could look like this:</p>

<pre><code>function _set(&amp;$key, $options, $default)
{
}
</code></pre>

<p>I know there's <code>array_key_exists()</code>, and I guess I'm sort of looking for a way to access the variables name.</p>

<p>For example:</p>

<pre><code>$apple = 'orange';
</code></pre>

<p>How can I get the string 'apple', so I can look for that key? I know I could take the function _set() and have it look for $key, $var, $options, and $default, but I'd rather abstract it further.</p>
