Jump to content

Help with returning multidimensional array


emilysnothere

Recommended Posts

Trying to retun an array which gets a file from a directory and then returns the filename as the key and the complete file url as the value but when returning it it prints out "Array" for each file in the directory rather than the file name:

Doing this in wordpress.

 

function wsme_select_css_theme(){
$alt_css_template_path = WSME_THEME_CSS; // Define path to files
$alt_widgets_template = array(); // set array
$out = ''; // Set var

if ( is_dir($alt_css_template_path) ) { // If directory exists
	if ($alt_css_template_dir = opendir($alt_css_template_path) ) { //opens directory
		while ( ($alt_css_template_file = readdir($alt_css_template_dir)) !== false ) { //if files are in the directory
			if(stristr($alt_css_template_file, ".css") !== false) { //if the files are .css files
				$out[] = array($alt_css_template_file => WSME_THEME_CSS.'/'.$alt_css_template_file); //create the array(filename => file path) for each file in the directory
			}
		}
	}
	return $out; // return array
}
}

 

 

array(
            'name' => 'Style',
            'id' => WS_THEME_PREFIX . '_style',
            'headings' => array(
                array(
                    'name' => 'Theme CSS',
                    'options' => array(
                        array('name' => 'Homepage',
                            'desc' => ' select the css file of the theme you want for your site',
                            'id' => WS_THEME_PREFIX . '_theme_css',
                            'value' => '',
                            'options' => wsme_select_css_theme(), 
                            'type' => 'select'
                        )
                    )
                )
            )

 

Any suggestions?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.