Finding similarities between images I've posted here before and got pretty helpful reviews. How does my code look now? To keep it really helpful, I just copied this from the middle of one of my projects.

 &lt;?php

  function findSimilarityBetweenImages($imagePathA, $imagePathB, $accuracy){

    //if images are png
    $imageA = imagecreatefrompng($imagePathA);
    $imageB = imagecreatefrompng($imagePathB);

    //if images are jpeg
    //$imageA = imagecreatefromjpeg($imagePathA);
    //$imageB = imagecreatefromjpeg($imagePathB);

    //get image resolution
    $imageX = imagesx($imageA);
    $imageY = imagesy($imageA);

    $pointsX = $accuracy*5;
    $pointsY = $accuracy*5;

    $sizeX = round($imageX/$pointsX);
    $sizeY = round($imageY/$pointsY);

    //Compare the color of each point while looping through.
    $y = 0;
    $match = 0;
    $num = 0;
    for ($i=0; $i &lt; $pointsY; $i++) {
      $x = 0;
      for($n=0; $n &lt; $pointsX; $n++){

        $rgba = imagecolorat($imageA, $x, $y);
        $colorsa = imagecolorsforindex($imageA, $rgba);

        $rgbb = imagecolorat($imageB, $x, $y);
        $colorsb = imagecolorsforindex($imageB, $rgbb);

        if(colorComp($colorsa['red'], $colorsb['red']) &amp;&amp; colorComp($colorsa['green'], $colorsb['green']) &amp;&amp; colorComp($colorsa['blue'], $colorsb['blue'])){

          $match ++; //Match between points.
        }
        $x += $sizeX;
        $num++;
      }
      $y += $sizeY;
    }
    //A similarity or percentage of match between the two images.
    $similarity = $match*(100/$num);
    return $similarity;
  }


  function colorComp($color, $c){
    //To see if the points match
    if($color &gt;= $c-2 &amp;&amp; $color &lt;= $c+2)
    {
      return true;
    }
    else
    {
      return false;
    }
  }

?&gt;
Since your question is about coding style, consider to adhere to PSR-2.

Your color comparision function is bloated. 'If the expression is true, then return true, else, if the expression is false, then return false.' Just return the expression.

return ($color &gt;= $c-2 &amp;&amp; $color &lt;= $c+2);


Next, I'd make the literal '2' variable, and add some DocBlock documentation:

/**
 * Check if two color components are similar
 *
 * @param  int  $color  The first color component's value
 * @param  int  $c      The second color component's value
 * @param  int  $dist   The maximum difference for two values to be considered equal
 *
 * @return boolean  True, if the color components are similar.
 */
function colorComp($color, $c, $dist)
{
    return ($color &gt;= $c-$dist &amp;&amp; $color &lt;= $c+$dist);
}