Linjon Posted June 19, 2011 Share Posted June 19, 2011 Hello. How to make script that adds number to name? Something like that: <?php $random = rand(10, 50); $name1 = "Jack"; $together = ($name1 + $random); ?> $together must be without space, example: jack32 Thanks! Link to comment https://forums.phpfreaks.com/topic/239828-add-number/ Share on other sites More sharing options...
meltingpoint Posted June 19, 2011 Share Posted June 19, 2011 <?php $random = rand(10, 50); $name1 = "Jack"; $together = $name1.$random; ?> Link to comment https://forums.phpfreaks.com/topic/239828-add-number/#findComment-1231952 Share on other sites More sharing options...
Linjon Posted June 19, 2011 Author Share Posted June 19, 2011 Wow, so fast. Thanks, it worked! Link to comment https://forums.phpfreaks.com/topic/239828-add-number/#findComment-1231954 Share on other sites More sharing options...
meltingpoint Posted June 19, 2011 Share Posted June 19, 2011 Link to comment https://forums.phpfreaks.com/topic/239828-add-number/#findComment-1231958 Share on other sites More sharing options...
Linjon Posted June 20, 2011 Author Share Posted June 20, 2011 I have some more questions but i will write these here. How can i edit php file via php? <html> <body> <form method="post"> <table> <tr><td>Age:</td><td><input type="text" name="age"></td> </tr> <tr><td><input type="submit" value="Submit" name="submit"></td></tr> </table> </form> </body> </html> if (isset($_POST['submit'])) { $myFile = "oldfile.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $age = $_POST['age']; fwrite($fh, $access); fclose($fh); echo "Done!"; } ?> Example: in oldfile.php should have age = "24" Link to comment https://forums.phpfreaks.com/topic/239828-add-number/#findComment-1231976 Share on other sites More sharing options...
meltingpoint Posted June 20, 2011 Share Posted June 20, 2011 linjon- start a new thread Link to comment https://forums.phpfreaks.com/topic/239828-add-number/#findComment-1231990 Share on other sites More sharing options...
Linjon Posted June 20, 2011 Author Share Posted June 20, 2011 Nah, can do it here too So, anyone know how to make that? I have some more questions but i will write these here. How can i edit php file via php? <html> <body> <form method="post"> <table> <tr><td>Age:</td><td><input type="text" name="age"></td> </tr> <tr><td><input type="submit" value="Submit" name="submit"></td></tr> </table> </form> </body> </html> if (isset($_POST['submit'])) { $myFile = "oldfile.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $age = $_POST['age']; fwrite($fh, $access); fclose($fh); echo "Done!"; } ?> Example: in oldfile.php should have $age = "24" Link to comment https://forums.phpfreaks.com/topic/239828-add-number/#findComment-1232450 Share on other sites More sharing options...
Psycho Posted June 20, 2011 Share Posted June 20, 2011 Nah, can do it here too So, anyone know how to make that? Yes, I do. But, I won't answer here because you don't want to start a new thread for a question that is unrelated to this post. Link to comment https://forums.phpfreaks.com/topic/239828-add-number/#findComment-1232462 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.