Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

For Ray (See related posts)

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; }


Comments on this post

joeldg posts on Oct 16, 2005 at 04:09
another way
of course depending on image naming..
where 0.gif is a 1x1 pixel clear gif.
$image_name = substr_count($content, '

') . ".gif";



or if coming from a database (i.e. data filtered through strip tags)

$image_name = substr_count($content, '\n') . ".gif";

You need to create an account or log in to post comments to this site.


Related Posts