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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.