1
glob
を使用してファイルを表示していて、各ファイル名を手動で入力したくない場合は、array_diff
を使用して削除します。それ以外の方法は、番号を持つファイル名を検索し、それらの要素を削除することでこれを改善する方法です。PHP:array_diff文字列に数字のない要素をすべて削除する
$dirs = 'D:/'.$type_of_store.'/LAB/'.$theSub.'/'.$subSub;
$theDirs = array_diff(glob($dirs.'/*.xml', GLOB_BRACE),
array(
'.',
'..',
'D:/'.$type_of_store.'/LAB/'.$theSub.'/'.$subSub.'/PosDataUpdatesStatus.xml',
CommCenterManagerConfig.xml,
ExternalReferences.xml
)
);
ファイル出力
CommCenterManagerConfig
ExternalReferences
PosDataUpdates-2016-10-27 094721
PosDataUpdates-2016-11-21 104425
PosDataUpdates-2016-11-21 110226
PosDataUpdates-2016-11-22 014654
PosDataUpdates-2016-11-22 062805
数を有し、かつ配列要素にそれを削除する文字列を検索する他の方法はありますか?
私のファイルが含まれているだけで文字列を表示する必要がある番号
PosDataUpdates-2016-10-27 094721
PosDataUpdates-2016-11-21 104425
PosDataUpdates-2016-11-21 110226
PosDataUpdates-2016-11-22 014654
PosDataUpdates-2016-11-22 062805