dongpiaozhao6836 2014-06-14 15:48
浏览 62

获取目录名称并在PHP中拆分它们

I have two problems.

Problem number one: Linux: I want to get only last folder names using ls:

Wrong - /home/test/ok/ok1/

Right - ok1

Currently I'm using command:

ls -d /home/test/*/*/

Problem number two: PHP: I want all directories names (from command's output - point 1) save to separate variables, dividing them into numbers and letters. For example we have 3 folders from the previous command:

ts2 OK4 oks67

I want each of them to write to the variable $foldername, and then receive two additional subvariables $foldername_1 (letter) and $foldername_2 (number)

Thanks in advance for any help! :)

  • 写回答

1条回答 默认 最新

  • dongningwen1146 2014-06-14 15:54
    关注

    To address your first problem, use basename

    $ basename /home/test/ok/ok1/
    ok1
    
    评论

报告相同问题?

悬赏问题

  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败