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 Link to comment https://forums.phpfreaks.com/topic/17596-help/ 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...... Link to comment https://forums.phpfreaks.com/topic/17596-help/#findComment-75003 Share on other sites More sharing options...
brown2005 Posted August 15, 2006 Author Share Posted August 15, 2006 awesome. exactly wat i wanted. thanks Link to comment https://forums.phpfreaks.com/topic/17596-help/#findComment-75015 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.