For Ray
In response to his question here, assuming your content is in a string called $content:
$num_paras = substr_count($content, ''); switch ($num_paras) { case 1: $image = 'one.jpg'; break; case 2: $image = 'two.jpg'; break; case 3: $image = 'three.jpg'; break; default: $image = ''; break; }