brown2005 Posted August 15, 2006 Share Posted August 15, 2006 <?php$a = RAND(1,1000);$numbers=array('1','2','3','4','5','6','7','8','9','0');$images=array('<img src="1.gif">','<img src="2.gif">','<img src="3.gif">','<img src="4.gif">','<img src="5.gif">','<img src="6.gif">','<img src="7.gif">','<img src="8.gif">','<img src="9.gif">','<img src="0.gif">');$b=str_replace($numbers,$images,$a);echo $b;?>i have the above code which outputs one result for $a... but is there away to turn this into a function so say i have like 5 different numbers...$f = "555";$e = "43545";$g = "45453";$h = "34553";$m = "34535";it would do the above to all of them and not just $a..any help would be appreciated..thanks Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 15, 2006 Share Posted August 15, 2006 function num_swap ($val){$numbers=array('1','2','3','4','5','6','7','8','9','0');$images=array('<img src="1.gif">','<img src="2.gif">','<img src="3.gif">','<img src="4.gif">','<img src="5.gif">','<img src="6.gif">','<img src="7.gif">','<img src="8.gif">','<img src="9.gif">','<img src="0.gif">');$b=str_replace($numbers,$images,$val);echo $b;}num_swap('555');num_swap('43545');and so on...... Quote Link to comment Share on other sites More sharing options...
brown2005 Posted August 15, 2006 Author Share Posted August 15, 2006 awesome. exactly wat i wanted. thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.