Rdogg112 Posted August 6, 2009 Share Posted August 6, 2009 umm, im making a game and characters HP so far is just text how would i make an image of about 1px X 5px show if the hp is 50 it would show 50 times like this: HP 50/100 could anyone help me? Link to comment https://forums.phpfreaks.com/topic/169092-repeat-image-depending-on-variable/ Share on other sites More sharing options...
watsmyname Posted August 6, 2009 Share Posted August 6, 2009 umm, im making a game and characters HP so far is just text how would i make an image of about 1px X 5px show if the hp is 50 it would show 50 times like this: HP 50/100 could anyone help me? <?php $hp=$_GET["hp"]; ?> <img src='line.jpg' width='<?php echo $hp; ?>' height='5px' /> Link to comment https://forums.phpfreaks.com/topic/169092-repeat-image-depending-on-variable/#findComment-892136 Share on other sites More sharing options...
alexdemers Posted August 6, 2009 Share Posted August 6, 2009 If it's 1 pixel large, stretching it is the best option. If, let's say you have hearts (like in Zelda), then you would need to repeat it using a simple for loop: <?php $lives = 4; for ( $i = 0; $i < $lives; $i++ ) { echo '<img src="/images/heart.png" alt="<3" /> '; } ?> Link to comment https://forums.phpfreaks.com/topic/169092-repeat-image-depending-on-variable/#findComment-892138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.