Re: how to join two arrays? [message #185716 is a reply to message #185715] |
Sun, 04 May 2014 19:47 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma:
|
Senior Member |
|
|
Jerry Stuckle wrote:
> On 5/4/2014 1:56 PM, Thomas 'PointedEars' Lahn wrote:
>> Denis McMahon wrote:
>>> then: array_merge ( $arr1, $arr2 );
>>>
>>> will generate:
>>>
>>> [0] "."
>>> [1] ".."
>>> [2] "foo.bar"
>>> [3] "really fubar"
>>> [4] "."
>>> [5] ".."
>>> [6] "bah bah.blacksheep"
>>> [7] "fufu.fubar"
>>>
>>> How you then tell which file is where, that's your headache at this
>>> point.
>>
>> array_map() serves here.
>
> And how can array_map() tell which file is where?
It cannot. However, if you apply array_map() to the arrays returned by
scandir() before merging them, the problem at hand does not occur in the
first place:
$modi = max(
array_map('filemtime',
array_diff(
array_merge(
scandir(__DIR__),
array_map(
function ($e) {
return 'sections' . DIRECTORY_SEPARATOR . $e;
},
scandir('sections')
)
),
array('.', '..')
)
)
);
HTH
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
|
|
|