Jump to content

[SOLVED] adding of variables


timmah1

Recommended Posts

This code worked fine, but now it don't

 

Can anybody tell me what's wrong?

 

<?php
$val=substr($val,0);
$price = explode(",", $val);
$tmp = number_format($price[1], 2);
$total_price += $tmp;
echo $total_price;
?>

 

It use to work regardless if there was one or two values for price[1]

 

Thanks in advance

Link to comment
Share on other sites

Most popular way to debug, echo variables out.  Here's your output, do you see what's going on here?

 

$val = 12345;
$val=substr($val,0);  //12345
$price = explode(",", $val);  //[0] => 12345
$tmp = number_format($price[1], 2); //0.00
$total_price += $tmp; //0
echo $total_price; //0
?>

 

Like Daniel is implying, we need more information.  What did you change?  What happens?  How did it used to work (example)?  etc...

Link to comment
Share on other sites

Guess if Daniel would of happened to explain it that way, I would've understood what they meant, my apologies for not posting enough code.

 

<?php
while (list ($name,$val) = @each ($_POST['package_'])) {  
		  
$val=substr($val,0);
$price = explode(",", $val);
$tmp1 = $price[1];
$total_price += $tmp1;
}
echo $total_price;
?>

 

The price of $_POST['package_'] is the second value

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.