so many ways, we can achieve below expected output, but here intention is, how to use multiple callback in array map and achieve the below expected output.
How to add multiple callback in array_map
<?php
$scandir = scandir('.');
echo "<pre>";
print_r($scandir);
$scandir = array_map('array_filter',array_map('callback',$scandir));
print_r($scandir);
function callback(&$var){
$curtime = time();
$filetime = filemtime($var);
$diff = $curtime - $filetime;
if ($diff < 2000){
return $var;
}
}
?>
Actual Output
Array
(
[0] => .
[1] => ..
[2] => array.php
[3] => array.php.bak
[4] => code-test.php
[5] => code-test.txt
[6] => code-test.txt.bak
[7] => code-test2.php
[8] => load-file.csv
[9] => load-file2.csv
)
Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
)
Expected Output
Array
(
[2] => array.php
[3] => array.php.bak
)