Archive

Posts Tagged ‘php’

lista plików z folderu w postaci html

April 7th, 2010 Marcin Wadowski Comments off

przydatne jeśli chcemy na szybko wygenerować sobie listę wszystkich plików z katalogu i opakować w #filename


/**
 * creating list.txt
 * ls > list.txt
 */

//const input output file
define('__INPUT_FILE__', "list.txt");
define('__OUTPUT_FILE__', "lista.html");

//wrapper for each line of input file
define('__PRE__','<a href="');
define('__MIDDLE__','">');
define('__SUFFIX__','</a><br/>');

//read input file into array
$list = file(__INPUT_FILE__);

//open output file to write and set pointer at the end of file
//if file does no exist attempt to create one
$file = fopen(__OUTPUT_FILE__, "a+");

//write each line into file into wrapper const
foreach($list as $value)
{
	$output = __PRE__ . $value . __MIDDLE__ . $value . __SUFFIX__;
	fwrite($file, $output);
}

//close file after finished
fclose($file);

SimpleXML

November 14th, 2008 Marcin Wadowski 1 comment

Jesli chcemy w PHP zczytać konkretne dane z pliku XML to chyba najprościej zaprząść do tego SimpleXML. Dokładna dokumentacja znajduje się na php.net al poniżej przedstawiam prosty przykład.
Read more…

Categories: XML, php Tags: , ,