$a="dir=desc&order=position&"
i want to replace = to -, & to -.
i using the following code:
$a = str_replace('&','-',$a);
$a = str_replace('=','-',$a);
it now turns to dir-desc-order-position-. but i want to get dir-desc-order-position. namely, the last character replace with null "".
You can use
rtrim($a,"-")to remove that character if it exists.