php - Remove part of string after third occurrence of certain character -
i have special case have whole range of different strings in array.
what need remove last part of string @ third occurrence of /.
example:
accessories / mens accessories / bags wallets / messenger bags /
so here want remove: messenger bags /
how possible php - remember have lot of different strings! can't take position it's different each time.
//here have 4 elements $parts = explode ('/', $string); //this glue first 3 elements list ($first, $second, $third) = $parts; //here can see desired result var_dump (implode ('/',array($first, $second, $third)));
output
string 'accessories / mens accessories / bags wallets ' (length=46)
Comments
Post a Comment