<?php
function ncd($x, $y) { 
  $cx = strlen(gzcompress($x));
  $cy = strlen(gzcompress($y));
  return (strlen(gzcompress($x . $y)) - min($cx, $cy)) / max($cx, $cy);
}   

echo (ncd('this is a test', 'this was a test').'<br />)';
echo (ncd('this is a test', 'this text is completely different'));
?>