I have a string in this format:
Each substring is seperated by ‘-‘
My question is how to move the last substring to the first as
Thanks a lot.
Here’s some code that’ll do it:
// Split the string into an array $letters = explode('-', 'A-B-C-X-Y'); // Pop off the last letter $last_letter = array_pop($letters); // Concatenate and rejoin the letters $result = $last_letter . '-' . implode('-', $letters);
Answered By – Michael Louis Thaler
Answer Checked By – Cary Denson (BugsFixing Admin)