I am pulling data from a feed and storing this as a string. In this data I have a price in ETH which looks like this:
string(12) "9.9121566185"
I want to convert this number to WEI and store it as a Money/Php object
When I try the following:
$money = new Money('9.9121566185', new Currency('ETH'));
echo $money->getAmount();
I get the error:
Amount must be an integer(ish) value
So I am thinking I need to do the following:
- Convert the string from ETH to WEI as an integer or 9912156618500000000
- As the number is big, I should use moontoast/math
- Once converted, I can store the new number as WEI in the Money object
- Go on holiday!
I am stuck on how to convert the ETH string value to a WEI value...