shamuraq Posted May 27, 2009 Share Posted May 27, 2009 Scenario: $a = 1; $b = rand(2,9); $c = $a/$b; Question: How do i store $c as fraction instead of it solving $a/$b? Thanx in advance... Link to comment https://forums.phpfreaks.com/topic/159868-variable-as-fraction/ Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 $c = $a . '/' . $b; That won't be simplified fraction. You'll have to do some math to get a simplified version. Link to comment https://forums.phpfreaks.com/topic/159868-variable-as-fraction/#findComment-843142 Share on other sites More sharing options...
shamuraq Posted May 27, 2009 Author Share Posted May 27, 2009 Thanx Ken... Link to comment https://forums.phpfreaks.com/topic/159868-variable-as-fraction/#findComment-843170 Share on other sites More sharing options...
dzelenika Posted June 25, 2009 Share Posted June 25, 2009 use class with public members $a and $b Example: clas fraction { public $a; public $b; } $c = new fraction(); $c->a = 5; $c->b = 7; Link to comment https://forums.phpfreaks.com/topic/159868-variable-as-fraction/#findComment-863280 Share on other sites More sharing options...
Ken2k7 Posted June 26, 2009 Share Posted June 26, 2009 use class with public members $a and $b Example: clas fraction { public $a; public $b; } $c = new fraction(); $c->a = 5; $c->b = 7; Why public members? I also don't get the point of this post. This problem is solved a month ago. Link to comment https://forums.phpfreaks.com/topic/159868-variable-as-fraction/#findComment-863818 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.