str_replace
Posted: Fri Oct 28, 2005 3:07 pm
hey just a question but im trying to make it to were im using this and I want it to display a number + another number like this
page1.php
page2.php
assuming they only enter numbers why wont this work? lol
like if msg=123 it would output 1+2+22+23+2
edit: btw if you didnt get this $in = 2
page1.php
Code: Select all
<input type="text" name="msg">
<input type="text" name="value2">
//plus all the submit junkCode: Select all
<?PHP
$msg = str_replace("1", "1+$in", $msg);
$msg = str_replace("2", "2+$in", $msg);
$msg = str_replace("3", "3+$in", $msg);
$msg = str_replace("4", "4+$in", $msg);
$msg = str_replace("5", "5+$in", $msg);
$msg = str_replace("6", "6+$in", $msg);
$msg = str_replace("7", "7+$in", $msg);
$msg = str_replace("8", "8+$in", $msg);
$msg = str_replace("9", "9+$in", $msg);
$msg = str_replace("0", "0+$in", $msg);
echo $msg;
?>like if msg=123 it would output 1+2+22+23+2
edit: btw if you didnt get this $in = 2