I a trying to remove the last character in my string. I have seen many examples to do that but all the methods are removing my all '&' but i want only my last character '&' to be removed.
My string is :
https://website.biz/get/#TYPE#? partner_id=XXXXXXXX&api_password=XXXXXXXX&mobile_no=#NUMBER#&operator_code=#OPERATORID#&amount=#AMOUNT#&partner_request_id=#ORDERID#&circle=10&recharge_type=NORMAL&
The complete API is dynamic. I want to remove the last string '&' from this string. The above line is coming from my PHP code :
<td><?php $parameter = fetchAPIparameter($v6['api_id'],$v6['operator_type']);
foreach ($parameter as $v7) {
$pks = ($v7['parameter'].'='.$v7['result'].'&'); echo ($pks);
} ?></td>
I have used substr($pks,0,-1)
and substr_replace($pks,"",-1)
and rtrim
and mb_substr
but all are removing the complete '&' from my API. Can you please help me what mistake i am doing.