Friday, 4 July 2014

PHP Drupal View to Array

function fun_View_to_Array($clinic_id, $fileType) {
    $view_get_field_details = views_get_view_result("pms_details", "page_4", $clinic_id, $fileType);
    //show_array($view_get_field_details);
    $array_field_list = array();
    if ($view_get_field_details) {
        foreach ($view_get_field_details as $fields) {
            $field_info = array();
            //print $fields->field_field_pms_field_validation_id[0]['raw']['target_id'];             

            $field_info['field_nid'] = $fields->nid;
            $field_info['field_name'] = $fields->node_title;
            $field_info['file_name'] = $fields->field_field_pms_file_name[0]['raw']['value'];
            $field_info['field_length'] = $fields->field_field_pms_field_length[0]['raw']['value'];
            $field_info['field_sequence'] = $fields->field_field_pms_field_sequence[0]['raw']['value'];
            $field_info['validation_nid'] = $fields->field_field_pms_field_validation_id[0]['raw']['target_id'];
            $field_info['clinic_id'] = $fields->field_field_pms_field_clinic_id[0]['raw']['target_id'];
            $field_info['Validation_message'] = $fields->field_field_pms_validation_message[0]['raw']['value'];
            $field_info['Validation_id'] = $fields->field_field_pms_validation_id[0]['raw']['value'];
            $array_field_list[] = $field_info;
        }
    }
    //print array2table($array_field_list);
    //show_array(array_filter($array_field_list, "Search_Function"));
    return $array_field_list;
}

No comments:

Post a Comment