- sscanf: documentation ( source)
- array_pad: documentation ( source)
<?php
$width = 300;
$height = 150;
$ratio = "2/1";
echo sscanf($ratio, '%d/%d');
list($numerator, $denominator) = array_pad(sscanf($ratio, '%d/%d'), 2, 1);
echo $numerator / $denominator == $width / $height ? 'true' : 'false';