We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

fris on 11/08/07


Tagged

math images


Versions (?)


highest common denominator


Published in: PHP 


routine i use when doing an uploading function and the image has to have a certain ratio ex: 4:6

  1. <?
  2. function get_divisor($x, $y)
  3. {
  4. if($x%1!=0 || $y%1!=0)
  5. return false;
  6. for($i=($x>$y?$y:$x);$i>0;$i--)
  7. {
  8. if($x%$i==0 && $y%$i==0)
  9. return $i;
  10. }
  11. }
  12. ?>

Report this snippet 

You need to login to post a comment.