public static function get_enrolment_data($data) {
        $enrolmethods = array();
        $enroloptions = array();
        foreach ($data as $field => $value) {

            // Enrolmnent data.
            $matches = array();
            if (preg_match('/^enrolment_(\d+)(_(.+))?$/', $field, $matches)) {
                $key = $matches[1];
                if (!isset($enroloptions[$key])) {
                    $enroloptions[$key] = array();
                }
                if (empty($matches[3])) {
                    $enrolmethods[$key] = $value;
                } else {
                    $enroloptions[$key][$matches[3]] = $value;
                }
            }
        }

        // Combining enrolment methods and their options in a single array.
        $enrolmentdata = array();
        if (!empty($enrolmethods)) {
            $enrolmentplugins = self::get_enrolment_plugins();
            foreach ($enrolmethods as $key => $method) {
                if (!array_key_exists($method, $enrolmentplugins)) {
                    // Error!
                    continue;
                }
                $enrolmentdata[$enrolmethods[$key]] = $enroloptions[$key];
            }
        }
        return $enrolmentdata;
    }
public static function get_enrolment_data($data) {
        $enrolmethods = array();
        $enroloptions = array();
        foreach ($data as $field => $value) {

            // Enrolmnent data.
            $matches = array();
            if (preg_match('/^enrolment_(\d+)(_(.+))?$/', $field, $matches)) {
                $key = $matches[1];
                if (!isset($enroloptions[$key])) {
                    $enroloptions[$key] = array();
                }
                if (empty($matches[3])) {
                    $enrolmethods[$key] = $value;
                } else {
                    $enroloptions[$key][$matches[3]] = $value;
                }
            }
        }

        // Combining enrolment methods and their options in a single array.
        $enrolmentdata = array();
        if (!empty($enrolmethods)) {
            $enrolmentplugins = self::get_enrolment_plugins();
            foreach ($enrolmethods as $key => $method) {
                if (!array_key_exists($method, $enrolmentplugins)) {
                    // Error!
                    continue;
                }
                $enrolmentdata[$enrolmethods[$key]] = $enroloptions[$key];
            }
        }
        return $enrolmentdata;
    }
public static function get_enrolment_data ( $ data ) { $ enrolmethods = array ( ) ; $ enroloptions = array ( ) ; foreach ( $ data as $ field => $ value ) { // Enrolmnent data. $ matches = array ( ) ; if ( preg_match ( '/^enrolment_(\d+)(_(.+))?$/' , $ field , $ matches ) ) { $ key = $ matches [ 1 ] ; if ( ! isset ( $ enroloptions [ $ key ] ) ) { $ enroloptions [ $ key ] = array ( ) ; } if ( empty ( $ matches [ 3 ] ) ) { $ enrolmethods [ $ key ] = $ value ; } else { $ enroloptions [ $ key ] [ $ matches [ 3 ] ] = $ value ; } } } // Combining enrolment methods and their options in a single array. $ enrolmentdata = array ( ) ; if ( ! empty ( $ enrolmethods ) ) { $ enrolmentplugins = self :: get_enrolment_plugins ( ) ; foreach ( $ enrolmethods as $ key => $ method ) { if ( ! array_key_exists ( $ method , $ enrolmentplugins ) ) { // Error! continue ; } $ enrolmentdata [ $ enrolmethods [ $ key ] ] = $ enroloptions [ $ key ] ; } } return $ enrolmentdata ; }
Extract enrolment data from passed data.

Constructs an array of methods, and their options:
array(
'method1' => array(
'option1' => value,
'option2' => value
),
'method2' => array(
'option1' => value,
'option2' => value
)
)

@param array $data data to extract the enrolment data from.
@return array
Extract enrolment data from passed data .