![]() |
PHP Coders
Was wondering how to code something like this.. or if there was a script that does this. Php or otherwise.
I want to take a bit of text with variables in it, duplicate it 50 times, and replace each variable with certain text that I have line by line in text files. Anyone? :helpme |
It's 4am and I haven't gone to bed yet, so I'm not going to be super helpful... but you could just store the strings you're wanting to use in an array and then either randomly or in order substitute into your "bit of text."
I do something kinda like that on some pages for an ad rotator. There is a php include that calls a separate file that I have different banners/ad-copy.. it just displays them randomly so surfers don't keep seeing the same one. I didn't want to bother creating a database for something so simple.. |
str_replace();
|
err nm sorry im drunka nd didn't read entire post.
First off you wanna do file_get_contents() to read the textfile in, Then explode(); on \n's then foreach($array as $i) { $var = str_replace('variable',$i,$originalstring); } |
That's pretty good for being drunk.
|
what can i say, im talented :P
|
Quote:
if you have to files that are exactly the same length in lines then you just have to read them both in... iterate the arrays... make your replacements and output the result. Code:
$file1 = file('path_to_first_file'); |
Code:
if (!empy($line)) { Code:
if (!empty($line)) { |
All times are GMT -7. The time now is 09:27 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123