I have a variable “$var” like the above.
And its modification like the below.
$left_of_the_first_delimiter= array_shift(explode('_', $var)); $right_of_the_last_delimiter=array_pop(explode('_', $var));
I can get the left of the first delimiter “a” and the right of the last delimiter “f” with the code above.
Now I like the get the left of the last delimiter “a_b_c_d_e”.
So I made the the code below.
$left_of_the_last_delimiter= str_replace('_'.array_pop(explode('_', $var)), '', $var);
So far so good.
Can I get the left of the third delimeter “a_b_c” with your help?