GetSimple Support Forum

Full Version: function help[CLOSED]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Thx to eveyone, solved.

this is the code:

Code:
function directoryToArray($directory, $recursive) {
    $array_items = array();
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($directory. "/" . $file)) {
                    if($recursive) {
                        $array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $recursive));
                    }
                    $file = $directory . "/" . $file;
                    $array_items[] = preg_replace("////si", "/", $file);
                } else {
                    $file = $directory . "/" . $file;
                    $array_items[] = preg_replace("////si", "/", $file);
                }
            }
        }
        closedir($handle);
    }
    return $array_items;
}

Code:
<?php

$directory=GSDATAUPLOADPATH;
$values=(directoryToArray($directory,true));
$datanext=$_GET['datanext'];
$data=$_GET['data'];
if($data!=NULL){
echo '<img src="'.$path.$data.'" width="600px" /><img src="'.$path.$datanext.'" width="600px" />';

}
else{echo'';}

while (list($key, $value) = each($values)) {
if($value!="." && $value!=".."&& $value!=".htaccess"){
echo '<img src="'.$values[$key].'"/><br />';
echo '<a href="http://localhost/GetSimple/index.php?id=php&data='.$values[$key].'&datanext='.$values[$key+1].'"><img src="http://localhost/GetSimple/data/uploads/'.$values[$key].'" width="100px" /></a>';
}
}
?>

and this is the error:

Warning: preg_replace() [function.preg-replace]: Unknown modifier '/' in E:\internet\EasyPHP-5.3.2i\www\GetSimple\theme\MyTheme\functions.php on line 22

for every file.

I've tried this code in a blank php page and it'works.
Where's the problem.

plugin exec-php is installed and html editor off.

Ciao
have you tried

Code:
$array_items[] = preg_replace("/\/\/\/s/i", "/", $file);

just a quick geuss no time to test yet
(sorry missed the ending / added that later)
THX.
Solved the problem about preg_replace.
Now i've a problem with the link...
GSDATAUPLOADPATH doesn't work. so I changed in

$directory="http://localhost/GetSimple/data/uploads/";

and now it retunrs another error:

Warning: opendir(http://localhost/GetSimple/data/uploads/) [function.opendir]: failed to open dir: not implemented in E:\internet\EasyPHP-5.3.2i\www\GetSimple\plugins\exec-php.php(30) : eval()'d code on line 4

any idea?
$array_items[] = preg_replace("/\/\/\/s/i", "/", $file);

when i update the page become

$array_items[] = preg_replace("////si", "/", $file);

idea?
ciao