Jump to content

[SOLVED] Spaces in an array?


maxudaskin

Recommended Posts

I take a one week break from PHP and look what happens.

 

<?php
include("./constants.php");

$stylesheet; // Set Variable for Later Use

if(!file_exists("styles/style.txt")){
    echo "<strong>An Error Has Occured: Cascading Style Sheet Setup File is Corrupt or missing. Reverting to default style.</strong>"; // Output Warning
$stylesheet = ROOTURL . "include/styles/default/default.css"; // Set Style Sheet as Default
}else{
    $style_text = preg_split("/\-\-\-/",implode('',file("styles/style.txt"))); // Get file contents and Split it up
$folder     = trim($style_text[1]); // Set the folder name
$file       = trim($style_text[3]); // Set the file name
echo ROOTURL . "include/styles/" . $style_text[1] . "/" . $style_text[3] . ".css<br /><br />";
if(file_exists(ROOTURL . "include/styles/" .  $folder . "/" . $file . ".css")){ // If the specified file exists
    $stylesheet = ROOTURL . "include/styles/" . $folder . "/" . $file . ".css"; // Set Style Sheet as Specified
}else{
    if($secondary == "default"){
	    $stylesheet = ROOTURL . "include/styles/default/default.css"; // Set Style Sheet as Default
	}else{
	    $folder = trim($style_text[5]); // Set the folder name
        $file   = trim($style_text[7]); // Set the file name

		if(file_exists(ROOTURL . "include/styles/" . $folder . "/" . $file . ".css")){
		    $stylesheet = ROOTURL . "include/styles/" . $folder . "/" . $file . ".css"; // Set Style Sheet as Specified
		}else{
		    $stylesheet = ROOTURL . "include/styles/default/default.css"; // Set Style Sheet as Default
		}
	}
}
}
?>

 

Style.txt

This file was written by Max Udaskin.
Please refer to the users manual before attempting to edit this file.

Standard


Folder Name
---
standard
---


File Name
---
red
---


===============
Secondary


Folder Name
---
standard
---


File Name
---
white
---

 

Output

http://www.virtualzoom.net/pirepdemo/include/styles/ standard / red .css

 

Note the spaces. What I want it to do is:

http://www.virtualzoom.net/pirepdemo/include/styles/standard/red.css

Link to comment
Share on other sites

You have set these variables ($folder, $file) and trimmed them, but do not use them.

<?php
$folder     = trim($style_text[1]); // Set the folder name
$file       = trim($style_text[3]); // Set the file name
echo ROOTURL . "include/styles/" . $style_text[1] . "/" . $style_text[3] . ".css<br /><br />";
?>

 

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.