13 gru 2008

Ilość plików w poszczególnych katalogach galerii

define ('PATH_IMAGE_GALERIA', PATH_IMAGE . 'galeria/');
foreach (glob(PATH_IMAGE_GALERIA.'*', GLOB_ONLYDIR) as $filename) {
$galeria_folder = substr(strrchr($filename, '/'), 1 );
$galeria_strony[$galeria_folder] = count(glob($filename . "/*.*"));
}
$dump = print_r($galeria_strony, true);
echo nl2br($dump);

Array
(
[php] => 4
[css] => 0
[javascript] => 0
[html] => 0
[http] => 1
[vba] => 0
[vbscript] => 1
)
25 lip 2008

Parsowanie dokumentu XML - przykład

$res = file_get_contents($url);
$content_start  = strpos($res, '</form>') + strlen('</form>');

$head_end       = $content_start;
$content_end    = strpos($res, '</xml-export>');
$foot_start     = strpos($res, '</xml-export>');

$head    = substr($res, 0, $head_end);
$content = substr($res, $content_start, $content_end - $content_start);
$foot    = substr($res, $foot_start);

$content = nl2br(html_entity_decode($content));
$content = htmlspecialchars_decode($content);
$content = UTF8toISO2($content);
$html_doc = $content;