获取目录名称并在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! :)

To address your first problem, use basename

$ basename /home/test/ok/ok1/
ok1