Question : PHP Edit File Date on The Server

Is there any code which will allow you to modify the creation or modified date of a file(s) on the web server? I need to create a test set of file with various dates spanning a year.

Thanks.

Answer : PHP Edit File Date on The Server

Good PHP book for those of us who are new to PHP:
http://www.sitepoint.com/books/phpmysql4/

You can filter with PHP regular expressions or with simple functions like strpos().  If Brian's function returns an array (confession: I did not read all of that solution, but I've seen a lot of work from bportlock and it is uniformly accurate) you can iterate over the array to remove the elements you do not want.

Here is a simple example using fabricated test data.  Does this help make sense of it?

best, ~Ray
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
<?php //RAY_filter_array.php
error_reporting(E_ALL);
echo "<pre>" . PHP_EOL;

function RAY_filter_array($array, $string)
{
    // ITERATE OVER THE ARRAY TO REMOVE ELEMENTS THAT DO NOT HAVE THE REQUIRED STRING
    foreach ($array as $key => $element)
    {
        // MAN PAGE: http://us.php.net/manual/en/function.strpos.php
        if (strpos($element, $string) === FALSE) unset($array[$key]); 
    }
    
    return $array;
}

// TEST DATA FOR THE FUNCTION
$arr = array
( 'foo'
, 'bar'
, 'baz'
)
;

// EXERCISE THE FUNCTION
var_dump(RAY_filter_array($arr, 'a'));
var_dump(RAY_filter_array($arr, 'ba'));
var_dump(RAY_filter_array($arr, 'baz'));
Random Solutions  
 
programming4us programming4us