Sunday 15 June 2014

php - Multiplication with first array value returning 0 always -



php - Multiplication with first array value returning 0 always -

i getting value database 67.00€ .i need multiple value integer. so, used explode function of php convert array , stored in variable $result.

print_r() follows:

array ( [0] => 67 [1] => 00€ )

now, if i'm multiplying first value of array value, result 0. like:

$result[0]*12

i tried convert first value integer using (int) $result[0] , intval($result[0]). both output 0

what doing wrong?

try this:

intval($result[0])* 12

i have tried , worked me. please create new file , run in localhost other project.

test.php

<?php error_reporting(e_all); ini_set('display_errors', 1); $str = '67.00$'; $result = explode('.',$str); print_r($result); $ans= intval($result[0])*12; // or $ans=($result[0])*12; both worked echo 'answer-->'.$ans; // 804 ?>

i don't know doing wrong. hope may able observe err.

php arrays currency currency-formatting

No comments:

Post a Comment