Jump to content
php.lv forumi

palidzat ar unlink


Speed

Recommended Posts

tatad folderii dem_zip ir sadi faili!

dfs-0610301425-awp_map5.dem

dfs-0610301404-de_aztec.dem

dfs-0610292249-fy_pool_day.dem

dfs-0610290455-cs_bank3.dem

utt

kaa ar php uztaisit lai izdzesas tie faili kam textaa 0610290455 ir 29 ! palidzat ja tas ir iespejams plz!

Link to comment
Share on other sites

Nebuus saistiits tieshi ar PHP, bet ar programmeeshanu kaa taadu: sheema sekojosha - 1) nolasaam foldera failu nosaukumus, ieliekam tos nosaukumus kaut kaadaa masiivaa 2) peec tam braucam cauri masiivam, un chekojam, vai tekstaa ir "29" 3) ja ir, izsaucam unlink.

 

PHP manuaali var atrast sadalju par masiiviem (arrays), ar to vari saakt. Par unlink funkciju, raadaas, Tu jau zini. Protams, jebkursh to programmu var uzrakstiit kaadas minuutes laikaa, bet tad jau Tev vairs nebuus interesanti.

Link to comment
Share on other sites

Nu jaa :) Teorija jau viegla

Karoche - ja php5, tad ielasam saturu ar scandir (vai kaut kas tamliidziigs) masiivaa

2) ejam pa masiivu un ar preg_match atrodam vajadziigo (neesmu profesionaalis, taapeec varu tikai mineet kodu

if (preg_match('/.*29.*/' $val)) unlink($val);

 

Nu kaut kas tml... Vot regulaaraa izteiksme gan jau klibo nenormaali - kaa jau teicu - ar taam man saskarsme maza :)

Edited by koko
Link to comment
Share on other sites

<?php
if ($handle = opendir('C:/AppServ/www/demo_zip/')) {
while (false !== ($file = readdir($handle))) {
$fails = fopen('fails.txt', 'a',);
$text = "
$file";
fwrite($fails, $text);
fclose($fails);
$arr file("fails.txt",'a')
if (preg_match('/.*29.*/' $val)) unlink($val);
};
};
?>

uzrakstiju shadu codu varbut tas ir nepareizi negribu lai izdzesas visi faili tapec negribas pasham parbaudt !

Link to comment
Share on other sites

es bik palaboju codu

<?php
if ($handle = opendir('C:/AppServ/www/demo_zip/')) {
while (false !== ($file = readdir($handle))) {
$fails = fopen('fails.txt', 'a');
$text = "
C:/AppServ/www/demo_zip/$file";
fwrite($fails, $text);
fclose($fails);
$arr = file("fails.txt", 'a');
if (preg_match('/.*29.*/', $text)) unlink($text);
};
};
?>

bet radas sitads suds == Warning: unlink( C:/AppServ/www/demo_zip/dfs-0610290023-de_box.dem.zip): Invalid argument in c:\appserv\www\delzip.php on line 10

Link to comment
Share on other sites

tnx tag sanaca bet vai nevar uztaisit lai man ik pa laikam nebutu japieraksta piem no 29 uz 30 no 30 uz 31 utt

<?php
$i = "27";
if ($handle = opendir('C:/AppServ/www/demo_zip/')) {
while (false !== ($file = readdir($handle))) {
$fails = fopen('fails.txt', 'a');
$text = "C:/AppServ/www/demo_zip/$file";
fwrite($fails, "\n".$text);
fclose($fails);
$arr = file("fails.txt", 'a');
$i++;
if (preg_match('/.*$i.*/', $text)) unlink($text);
};
};
?>

meginaju sita bet nesanaca !

Link to comment
Share on other sites

×
×
  • Create New...