Cant seem to figure this out.. I have a JavaScript function that gets the value of all elements with the same class name:
var total = $(".bob").map(function() {
return $(this).val();
}).get();
var queryString = "?total="+total;
http.open("GET", "product.php" + queryString, true);
http.onreadystatechange = rgetHttpRes;
http.send(null);
I am passing the array to my php file -
if (isset($_GET['total'])) {
$price = $_GET['total'];
$num = array($price);
$result = array_sum($num);
echo($result);
}
// So I passed 2 integers with the JavaScript function: 15.99 and 10.99 into this php function.
It will only return one of them: 10.99 //
When I do this:
if (isset($_GET['total'])) {
$price = $_GET['total'];
$num = array($price);
print_r($num);
}
this is the output I get:
Array ( [0] => 15.99, 10.99 )
I can't figure out why it wont print them like
Array ( [0] => 15.99 [1] => 10.99 )
Does anyone have any ideas?