Hello everyone,
I'm new to PHP, so please go easy on me! :eek:
I am writing a web page for people to choose some items. One of the functions I have is to remove the "$" signs from prices, then multiply them times the number of items the person is asking for. Sounds simple, right? So I thought. I'm getting a "Fatal error: Can't use function return value in write context in..." error and I can't figure out why. Any assistance would be greatly appreciated.
Here is my function code:
//function that clears the "$" sign and gets the cost for the item
function item_cost($cost, $amount)
{
$cost2 = preg_replace("/[^a-zA-Z0-9s.]/", "", $cost); //removes the "$" sign
$cost1 = (float)$cost2; //makes sure the variable is a number
$amount1 = (float)$amount; //makes sure the variable is a number
$x= $cost1 * $amount1; //multiplies the amount ordered by the number ordered
return $x;
}
Here is the line that calls the function:
$item_price($i)= item_cost($price[$i], $amount_ordered);
The line number the error gives me is the above function call.
Thanks everyone!!