xxreenaxx1 Posted March 8, 2011 Share Posted March 8, 2011 can you have something like.. echo $whatever; this putput 1.2 can you split this number so the first integer will be in $val"(1)" or whatever and the second integer after the "." will be in $val2"(2)" Link to comment https://forums.phpfreaks.com/topic/229963-numbers-and-php/ Share on other sites More sharing options...
silkfire Posted March 8, 2011 Share Posted March 8, 2011 $val = array(floor($whatever), $whatever - floor($whatever)); echo $val[0], '<br>'; echo $val[1]; Link to comment https://forums.phpfreaks.com/topic/229963-numbers-and-php/#findComment-1184391 Share on other sites More sharing options...
xxreenaxx1 Posted March 8, 2011 Author Share Posted March 8, 2011 You are awesome......... One more question. When I print my second value. its does 0.3 or 0.1 or whatever Link to comment https://forums.phpfreaks.com/topic/229963-numbers-and-php/#findComment-1184405 Share on other sites More sharing options...
silkfire Posted March 8, 2011 Share Posted March 8, 2011 Oh sorry didn't really test the code =P Could this work better? $val = array(floor($whatever), substr(strstr($whatever, '.'), 1)); echo $val[0], '<br>'; echo $val[1]; Link to comment https://forums.phpfreaks.com/topic/229963-numbers-and-php/#findComment-1184410 Share on other sites More sharing options...
xxreenaxx1 Posted March 8, 2011 Author Share Posted March 8, 2011 Thank you . It works Link to comment https://forums.phpfreaks.com/topic/229963-numbers-and-php/#findComment-1184411 Share on other sites More sharing options...
xxreenaxx1 Posted March 8, 2011 Author Share Posted March 8, 2011 I dont see the solved button. But this has been solved Link to comment https://forums.phpfreaks.com/topic/229963-numbers-and-php/#findComment-1184412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.