04.07.2018, 03:44
Hello guys, I want to devide this string "21.99" into two part, cash: "21" and coin: "99". I do this and it works, but I think it may be slow. Can you help me optimize it?
Output:
Thanks in advanced.
PHP код:
new _money[11] = "21.99",
cash[11],
coin[3],
_cash,
_coin,
dot;
dot = strfind(_money, ".");
if(dot != 1)
{
strmid(cash, _money, 0, dot);
strmid(coin, _money, dot+1, dot+3);
_cash = strval(cash);
_coin = strval(coin);
printf("money: %s, cash: %d, coin: %d", _money, _cash, _coin);
}
Quote:
money: 21.99, cash: 21, coin: 99 |