How to remove the first two directories from a file path string?
问题 I have a string "./product_image/Bollywood/1476813695.jpg". first I remove . from first. now I want to remove all character between first two / . that means I want Bollywood/1476813695.jpg I am trying with this but not work substr(strstr(ltrim('./product_image/Bollywood/1476813695.jpg', '.'),"/product_image/"), 1); It always return product_image/Bollywood/1476813695.jpg 回答1: Easily done with explode() : $orig = './product_image/Bollywood/1476813695.jpg'; $origArray = explode('/', $orig); $new