Jump to content

Archived

This topic is now archived and is closed to further replies.

brown2005

help

Recommended Posts

<?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

Share this post


Link to post
Share on other sites
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......

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.