php - Round only int of variable -


i busy webshop, , have issue:

i display quantity of products, , attribute of product.

like:

2,4 cm 2,56 dm 

now want round numbers of variable, if use:

$qty = round($_product->getbundle_qty()); 

but if use: $aantal = $_product->getbundle_qty(); works okay, doesn't round.

then attribute doesn't show anymore ( dm, cm, m etc)

can me?

is $_product->getbunlde_qty() double or float? or string? in case, can use:

$qty = round(floatval($_product->getbundle_qty())); 

edit: if want keep cm / dm in behind string can take string , explode @ spaces, creating array string. last value in array 'cm' or 'dm' text.

$qtypieces = explode(" ", $_product->getbundle_qty()); //explode @ space $qtypiecescount = count($qtypieces); //count pieces $qty = round(floatval($_product->getbundle_qty())) . " " . $qtypieces[$qtypiecescount - 1]; //get last value in array, count minus 1 because start counting 0 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -