Displaying values on hook_form I'm displaying a form on admin url :admin/settings/custom. In the page argument I pass array('custom_admin_form'), to the menu item. In the form function I'm writing form elements to display folder and file names present in the public folder. I get those values through the code below:

$dir_path = variable_get('file_public_path', conf_path(). '/files') ;
$fileslist = glob($dir_path . "*.*"); 
$dirs = glob($dir_path . '/*' , GLOB_ONLYDIR);
foreach($dirs as $directs){
     $names = explode('/', $directs);
     $fnames[] = end($names);
}


How can I display the results in the form function? I tried it using print, echo, drupal_render but nothing is working. I've also used #markup element, but it was displaying array(), not the values of array.
You can try something like this:

 $form['sample'] = array(
     '#type' =&gt; 'item',
     '#markup' =&gt; print_r($sample_values, TRUE),        
 ); 


or simply just

print_r($sample_values);


or install Devel module and use dsm function.

dsm($sample_values);


UPDATE:

Try this:

$form['sample'] = array(
    '#type' =&gt; 'item',
    '#markup' =&gt; print_array_values($sample_values),        
); 


Then declare the function below:

function print_array_values($sample_values){
    $content = '';
    foreach($sample_values as $val){
            $content .= '&lt;div&gt;' . $val . '&lt;/div&gt;';
    }

    return $content;
}