我有一个包含照片的文件夹,需要在页面上显示。 我读了一个数组中的所有照片,然后按日期对它们进行排序。
在按日期排序之后,我需要将所有带有第一个字符'_'的照片放在数组的顶部。通过这种方式,它们将首先显示在页面上。
我不想使用其他import tensorflow as tf
import numpy as np
tf.enable_eager_execution()
x = tf.constant([1., 2.])
print(type(x)) # <type 'EagerTensor'>
print(type(x.numpy())) # <type 'numpy.ndarray'>
print(type(np.array(x))) # <type 'numpy.ndarray'>
因为执行时间太长。
我怎么能这样做?
foreach
答案 0 :(得分:0)
您可以将其整合到usort
来电中:
usort($files, function ($a, $b) {
$bsa = basename($a);
$bsb = basename($b);
if ($bsa[0] == '_' && $bsb[0] != '_') // a starts with _ but b doesn't
return -1;
else if ($bsa[0] != '_' && $bsb[0] == '_') // b starts with _ but a doesn't
return 1;
else // both start with _ or both don't
return (filemtime($b) - filemtime($a));
});