2
0

helpers_file.php 609 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. if (!function_exists('filepath_join')) {
  3. /**
  4. * @param ...$paths
  5. * @return string
  6. */
  7. function filepath_join(...$paths): string
  8. {
  9. $cleanedPaths = [];
  10. foreach ($paths as $path) {
  11. $path = trim($path);
  12. $path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path);
  13. if (empty($path)) {
  14. continue;
  15. }
  16. $path = rtrim($path, DIRECTORY_SEPARATOR);
  17. $cleanedPaths[] = $path;
  18. }
  19. return implode(DIRECTORY_SEPARATOR, $cleanedPaths);
  20. }
  21. }