Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with my function, please

Status
Not open for further replies.

alfordjj

MIS
Jul 23, 2003
80
0
0
US
I'm getting a "Fatal error: Can't use function return value in write context in..." error and I'm not sure why. I'm certain I'm missing some little thing somewhere, but I can't see it. I'm hoping one of you people who always seem to be much brighter than myself can point out what I'm doing wrong.

Here is the 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:

Code:
$item_price($i)= item_cost($price[$i], $amount_ordered);

The function is supposed to strip off any "$" and then multiply the two numbers together.

Thanks everyone!!
 
Durrrrr...... I found it. I put () instead of [] on the array.

God made me stupid to keep me humble, I guess! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top