Question: I need to open new WPA/WPA2 device from linux c code.
Now I create it manualy by using wpa\_supplicant

```
wpa_supplicant -iwlan0 -c connfig.conf -B

```

* How I can to start it from my code (without using system() )?
* What wpa\_supplicant interface is intended for this ?

Maybe, do you have any example ?
hanks in advance

Answer: 
Use a [reference](http://php.net/language.references) to refer to the latest known point in the array and update it with each step:

```
$ref = &$this->config;
$keys = explode('.', $name);
foreach ($keys as $idx => $key) {
    if (!is_array($ref)) {
        // reference does not refer to an array
        // this is a problem as we still have at least one key to go
    }
    if (!array_key_exists($key, $ref)) {
        // key does not exist
        // reaction depends on the operation
    }
    // update reference
    $ref = &$ref[$key];
}

```

The `if` branches depend on the operation. Here’s an example for the getter and setter:

```
public function get($name) {
    $ref = &$this->config;
    $keys = explode('.', $name);
    foreach ($keys as $idx => $key) {
        if (!is_array($ref)) {
            throw new Exception('key "'.implode('.', array_slice($keys, 0, $idx-1)).'" is not an array');
        }
        if (!array_key_exists($key, $ref)) {
            throw new Exception('key "'.implode('.', array_slice($keys, 0, $idx)).'" does not exist');
        }
        $ref = &$ref[$key];
    }
    return $ref;
}
public function set($name, $value) {
    $ref = &$this->config;
    $keys = explode('.', $name);
    foreach ($keys as $idx => $key) {
        if (!is_array($ref)) {
            throw new Exception('key "'.implode('.', array_slice($keys, 0, $idx)).'" is not an array but '.gettype($ref));
        }
        if (!array_key_exists($key, $ref)) {
            $ref[$key] = array();
        }
        $ref = &$ref[$key];
    }
    $ref = $value;
}

```
I have another solution based on eval
I just concatenate the strings with brackets around

```
<?php
Class foo {
    private $config=array();

    function __construct(){    
        $this->config['site']['title'] = 'testing';
        $this->config['site']['favicon'] = 'XXXXX.ico';
        $this->config['site']['keywords'] = array('page','cute','other');        
        $this->config['otherthing'] = 'value';
        /**etc**/
    }

    public function set($name,$value)
    {
        $tmp = explode('.',$name);
        $array_levels = "['";
        foreach($tmp as $key) {
            $array_levels .= $key."']['";
        }
        $array_levels = substr($array_levels, 0, -2);
        eval('$this->config'.$array_levels.' = $value;');
    }
    public function get($name)
    {
        $tmp = explode('.',$name);
        $array_levels = "['";
        foreach($tmp as $key) {
            $array_levels .= $key."']['";
        }
        $array_levels = substr($array_levels, 0, -2);
        eval('$value = $this->config'.$array_levels.';');
        return $value;
    }
}
$thing = new foo;
$thing->set('site.keywords',array('other','keywords'));
echo $thing->get('site.title');

```