PHP String to Float
        Posted  
        
            by John
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by John
        
        
        
        Published on 2009-01-26T21:32:22Z
        Indexed on 
            2010/04/19
            10:53 UTC
        
        
        Read the original article
        Hit count: 160
        
I am not familiar with PHP at all and had a quick question.
I have 2 variables @pricePerUnit and @invoicedUnits. Here's the code that is setting these to values:
$InvoicedUnits = ((string) $InvoiceLineItem->InvoicedUnits);
$pricePerUnit = ((string) $InvoiceLineItem->PricePerUnit);
If I output this, I get the correct values. Lets say 5000 invoiced units and 1.00 for price.
Now, I need to show the total amount spent. When I multiply these two together it doesn't work (as expected, these are strings).
But I have no clue how to parse/cast/convert variables in PHP.
What should I do?
© Stack Overflow or respective owner