You are here: Re: trouble with a delete function « PHP Language « IT news, forums, messages
Re: trouble with a delete function

Posted by skare_krow on 10/09/18 11:37

David Haynes wrote:
> Janwillem Borleffs wrote:
>
>> David Haynes wrote:
>>
>>> If you want to know if *any* unlink was unsuccessful:
>>> $success=true;
>>> foreach($file_arr as $file) {
>>> $success |= unlink($file);
>>> }
>>
>>
>> $success = false;
>> foreach (......)
>>
>>> If you want to know which unlink failed:
>>> foreach($file_arr as $file) {
>>> if( unlink($file) ) {
>>> echo "Cannot unlink $file\n";
>>> }
>>> }
>>>
>>
>> if ( ! unlink($file) ) {
>> ....
>> }
>>
>>
>> JW
>>
> My bad ;-)
> You are correct.
>
> -david-
>

Thank you all. This is what I ended up doing, I will probably expand on
this testing for certain cases (existence of file, delete
success/failure) but a big thanks. Here is the code that worked for me.
I could probably do this differently.

Thanks,
Aaron


function file_delete($file) {
if(unlink($file))
return true;
return false;
}

//Use the function file_delete:
for($i = 0; $i <= 5; $i++) {
$file = "../images/".$file_arr[$i];
file_delete($file);
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация