Új hozzászólás Aktív témák

  • trisztan94

    őstag

    Elvtársak!

    Lenne egy történetfeltöltésem, ami txt filekba menti az anyagot, ami a biralas_tortenetek könyvtárban van. Na, ezt szeretém most kilistázni, de úgy, hogy csak az első 200 karakter látszódjon és legyen egy gomb amivel meglehet nézni az egészet. Egyik angliai ismerősömtől kaptam erre egy kódot, de sehogy sem tudom beüzemelni:

    <?php
    $dataArray = array();
    //Number of chars for the string
    $num = 200;

    //Check if DIR exists
    if ($handle = opendir('../php/biralas_tortenetek/')) {
    //Loop over the directory
    while (false !== ($file = readdir($handle))) {
    //Strip out the . and .. files
    if ($file != "." && $entry != "..") {
    $dataArray[] = array();
    //Store file contents
    $filecontent = file_get_contents($file);
    //Split the content and store in array
    $length = strlen($filecontent);
    $dataArray[] = array(substr($filecontent, 0, $num), substr($filecontent, $num, $length ));
    }
    }
    //close the dir
    closedir($handle);
    }
    ?>

    <?php foreach($dataArray as $data) { ?>
    <div class="visible">
    <?php echo $data[0]; ?>
    </div>
    <div class="hidden">
    <?php echo $data[1]; ?>
    </div>
    <?php } ?>

    Mi a baj? :(

    Bocsi, hogy napi 8x itt kérdezgetek, rendesek vagytok, hogy segítetek :D

Új hozzászólás Aktív témák

Hirdetés