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
https://forums.phpfreaks.com/topic/114014-solved-spaces-in-an-array/
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 />";
?>

 

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.