String replacing with regular expression
suggest change$string = "a;b;c\nd;e;f";
// $1, $2 and $3 represent the first, second and third capturing groups
echo preg_replace("(^([^;]+);([^;]+);([^;]+)$)m", "$3;$2;$1", $string);
Outputs
c;b;a
f;e;d
Searches for everything between semicolons and reverses the order.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents