- var_dump: documentation ( source)
- number_format: documentation ( source)
<?php
$px = '1000px';
var_dump((int)$px);
function get_cm_by_px($px, $dpi = 300, $precision = 2) {
$comma = ','; // if US use '.'
return number_format(2.54 * (int)$px / $dpi , $precision, $comma,'') ;
}
get_cm_by_px($px);