Character transfer and truncation problems! Assume that the string $ a = 123/frew/4214/fsdf/123/123/dsa; $ a is a variable and the content changes. Then, how to intercept the content from the beginning to the second to the last & quot;/& quot;, that is, 123/frew/4214/fsdf/123/. do not intercept the content from the previous character!
Assume that the string $ a = 123/frew/4214/fsdf/123/123/dsa; $ a is a variable and the content changes.
Then, how to extract the content from the start to the last two "/", that is, 123/frew/4214/fsdf/123/
Do not start counting "/" from the beginning, because you are not sure how many '/' are in the front, and you know that you do not want to count the content after the second.
------ Solution --------------------
$ T = explode ('/', $ );
Echo join ('/', array_slice ($ t, 0,-2 )).'/';
------ Solution --------------------
PHP code
$ A = '2017/frew/123/fsdf/4214/dsa '; $ t = explode ('/', $ a); echo join ('/', array_slice ($ t, 0,-2 )). '/';
------ Solution --------------------
$ A = explode ('/', $ );
$ S [count ($ s)-1] try
------ Solution --------------------
$ B = join ('/', array_slice ($ t, 0,-2 )).'/';
------ Solution --------------------
Are you kidding me on the 6th floor?
$ A = '2017/frew/123/fsdf/4214/dsa ';
$ T = explode ('/', $ );
$ B = join ('/', array_slice ($ t, 0,-2 )).'/';
Echo $ B;