Jump to content
  • 0

pomoc [HELP-PhP] vypsaní souborů


MinecraftPlayer

Dotaz

11 odpovědí na tuto otázku

Recommended Posts

  • 0

Poradím ti

<?php
$cesta = "/cesta/k/zlozke/"; //Nastavime zlozku
$subory = Array();
if ($dir = opendir($cesta)) { //Otvarame resource
    /* Vypisujeme subor a ulozujeme do array */
    while (false !== ($subor = readdir($dir))) {
        $subory[$subor] = file_get_contents($subor);
    }
    closedir($dir); //Zavreme zlozku
}
//Vypis:
foreach($subory as $subor => $obsah) {
echo "Subor: $subor, Obsah: $obsah".PHP_EOL;
}
?>

Link to comment
Share on other sites

  • 0

Ano šlo.

$file = file('subor.php');
$radek = 42; //Radek na kterem mas tu promennu

// Kdyz chces jenom vypsat promennu na obrazovku a ne nastavit ji tak pouzi tohle:
echo $file[$radek];
//Kdyz chces tu promennu hned i nastavit tak pouzi tohle:
eval($file[$radek]);

Link to comment
Share on other sites

  • 0

Tu máš.. len nahradíš kód.

    while (false !== ($subor = readdir($dir))) {
        if($soubor == "." || $soubor == "..") continue;
        $subory[$subor] = file_get_contents($subor);
    }

Link to comment
Share on other sites

  • 0

Tak použi toto :d

Nahradíš ..

Nahrad toto:
$subory[$subor] = file_get_contents($subor);
S Tym:
$ext = explode('.',$subor);
$ext = $ext[0];
$subory[$ext] = file_get_contents($subor);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...