I am trying to write a very simple statement that will make it so that, if users of my blog don't have a gravatar, an image chosen randomly will appear. The way it works now is like this:
<?php echo get_avatar( $comment, $size = '78', $default = '/images/noavatar2.gif' ); ?>
this will give me a random number:
echo(rand(1,10)
I want to echo the random number between "noavatar" and ".gif" but I can't seem to figure out how to do it. Any help would be appreciated.
Try this:
<?php echo get_avatar( $comment, $size = '78', $default = '/images/noavatar' . rand(1,10) . '.gif' ); ?>
This uses a language feature called string concatenation; for more information on how this works in PHP: http://www.phpf1.com/tutorial/php-string-concatenation.html
'/images/noavatar'.rand(1,10).'.gif'