470,833 Members | 1,203 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.



I've got a tiny little problem :-) with the following code:


function get_styles($dir) {
$tmp = scandir($dir); // Line 19
echo $dir; echo $tmp;
foreach ($tmp as $key => $datei) {
if (substr($datei, -3) == "css") {
$tmpdatei = substr($datei, 0, (strlen($datei) - 4));
$trimmed_array[$key] = $tmpdatei; }
return $trimmed_array;

function init_styleswitcher() {
if (!isset($_SESSION['styles'])) { $_SESSION['styles'] =
get_styles($cssdir); }


I get these Errormessages, the 2nd and the 3rd are consequences of the
first I suppose:

Warning: scandir() [function.scandir.html]: (errno 22): Unknown error: 0
in /home/designw/public_html/styleswitcher/phplib/styleswitcher.php on
line 19

Warning: Invalid argument supplied for foreach() in
/home/designw/public_html/styleswitcher/phplib/styleswitcher.php on line 21

Warning: in_array() [function.in-array.html]: Wrong datatype for second
argument in
/home/designw/public_html/styleswitcher/phplib/styleswitcher.php on line 34

This function doesn't work anymore since I try to use it in sessions and
I don't understand it. Can anyone give me a hint?

Feb 26 '06 #1
2 1621
What's the value of $dir?

Feb 27 '06 #2
Looking closer at your code i think i spotted the problem. $cssdir
needs to have global scope or else init_styleswitcher() needs an
argument passed to it. In this case init_styleswitcher($cssdir).
If you don't want to add an argument to init_styleswitcher() then you
change get_styles($cssdir); to get_styles($GLOBALS['cssdir']);

Feb 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by David Callan | last post: by
14 posts views Thread by Sean C. | last post: by
15 posts views Thread by Hemant Shah | last post: by
4 posts views Thread by JR | last post: by
2 posts views Thread by CptDondo | last post: by
165 posts views Thread by Dieter | last post: by
3 posts views Thread by Michel Esber | last post: by
7 posts views Thread by Sheldon | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.