I would imagine that the processing time involved in using basename() on each entry is negligible compared to the initial file system access to retrieve the names. Certainly, using a PHP inbuilt function is going to be faster than a Yii implemented OO approach, as the PHP libraries are built in C rather than interpreted at run time.
I’d just iterate through the files in the manner you suggested.
I was imagine the CFileHelper::findFiles had a parameter to fetch directly the name of files by using php function (so faster as you say) rather than to
fetching all the file names with absolute path and then take the name by basename (2 commands for 2 iterators)
In details:
-(the way to do that now)-
get all files with absolute path
get the received list and foreach item remove the absolute path
get the modified list and concatenate with base url
-the way that I want
get ditectly the name of files
get the list and concatenate with base url
-the best way
get the url of file (www.mydomain.gr/images/img01.jpg,www.mydomain.gr/images/img02.jpg) foreach file
For few files there is no problem cpu-ram consuming but for many files and many http requests the differents may could be significant
You might want to make your own helper function that uses glob().
Yii’s function is designed to allow recursive scanning of directories, so returning just the file names wouldn’t be sensible in that context. This would need to be a separate function.
I still think that there’s no need to optimise this function though, you could just create a helper function to process the files using the method discussed previously.