FT3 Posted February 21, 2012 Report Share Posted February 21, 2012 Sveiki ir problema neka nevaru atrisinat .. iekš input ir šadi value value="0.15 Ls" value="0.30 Ls" value="0.45 Ls" value="0.60 Ls" value="0.75 Ls" value="0.95 Ls" value="1.25 Ls" value="1.50 Ls" value="1.75 Ls" value="2.00 Ls" ka izdarit ta lai pie $_POST izvada 15 , 30 , 125 u. c. Iepriekš paldies :) Quote Link to comment Share on other sites More sharing options...
Dooling Posted February 21, 2012 Report Share Posted February 21, 2012 $test="0.95 Ls"; echo intval(str_replace(".","",$test)); Quote Link to comment Share on other sites More sharing options...
daGrevis Posted February 21, 2012 Report Share Posted February 21, 2012 Kāpēc tur ir tādi values? Kas vainas, piemēram, 0.15 Ls pierakstīt kā 15? Ja tomēr gribi ļoti čakarēties... extracto ar regexu ārā digiti/punks/digiti (vai tā kā Dooling minēja). Quote Link to comment Share on other sites More sharing options...
marrtins Posted February 21, 2012 Report Share Posted February 21, 2012 $realvalue = preg_replace("/[^\d\.]/", '', $value) * 100; Quote Link to comment Share on other sites More sharing options...
Maris-S Posted February 22, 2012 Report Share Posted February 22, 2012 Tā teikt īsti nevaru izprast neko no Tavas matemātikas, bet panāk to varētu kaut vai tā: intval(floatval("1.25") * 100) ja protams tie skaitļi tur vienmēr būs tāda veida un neko papildus nav jāpārbauda. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.