Jump to content

2000a

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Posts posted by 2000a

  1. Hi,

     

    How can I check if a variable only has these characters:

    - number (0-9)

    - decimal point (.)

    - positive (+)

    - negative (-)

    - dollar ($)

     

    I tried is_numeric, but it doesn't like negative values...

     

    I need to add the variable value to another variable. I have to accept numbers (including negative and decimals)...

     

    ex:

    0.1 = TRUE

    -.1 = TRUE

    12 = TRUE

    1000.00 = TRUE

    12a = FALSE

     

     

     

    thanks

  2. Hi,

     

    I need YOUR help with a piece of code. My body normally helps me, but he's on vacation.

     

    I have a folder (/var/www/html/upload/files/) where files are uploaded to. There can be files at the root of (/uploads/) and there can be files in subfolders of  (/uploads/)... eg: (/uploads/subfolder1/files_here), (/uploads/subfolder2/files_here)

     

    I want to modify my script (below) that only delete old files at the root (/uploads/), to also delete files (but NOT subfolders) older than 10 days. Do not delete subfolders, regardless of date.

     

    You can modify the existing code to make it more efficient, if you have time/patience.

    I'm grateful for your help.

     

    This is the code I have for the root folder (not recursive):

    $dir = '/var/www/html/upload/files/';

     

    echo "STARTING\n";

    if (is_dir($dir)) {

    if ($dh = opendir($dir)) {

    while ($file = readdir($dh)) {

    if(!is_dir($dir.$file)) {

    if (filemtime($dir.$file) < strtotime('-10 days')) { //if 10 days old, delete

    echo "Deleting $dir.$file (old)\n";

    unlink($dir.$file);

    }

    }

    }

    } else {

    echo "ERROR. Could not open directory: $dir\n";

    }

    } else {

    echo "ERROR. Specified path is not a directory: $dir\n";

    }

    closedir($dh);

    echo "DONE\n";

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.