Can anyone tell me what I'm doing wrong here: :o
The array variable keeps showing as "Array" in the output.
<?php
//$words = './wordz.txt';
//$articles = './articles.txt';
//$domains = './domains.txt';
//$wordlist = file_get_contents($words);
//$articles_array = file_get_contents($articles);
//$domains_array = file_get_contents($domains);
$filename = "./articles.txt";
$handle = fopen($filename, "r");
$articles = fread($handle, filesize($filename));
fclose($handle);
$wordlist = array("wedding", "BS");
$replacement = array("WEDDING", "CACA");
$dom = "domain.com";
//$newphrase = str_replace($wordlist, $replacement, $articles);
// :mad:
$newphrase = [COLOR=Red](str_replace($wordlist, '<a href="http://' . $dom . '">' . $replacement . '</a>', $articles));
[/COLOR]
print $newphrase;
//print $articles_array;
//print $wordlist;
//print $domains_array;
?>
Here is the output sample:
savor of all successful <a href="http://domain.com">Array</a>s to take center stage
Array is suppose to be WEDDING
It works when I don't attempt to include anything else in the "replace" field other than $replacement.
Also, does the "filez.txt" have to be in a specific format e.g. "word","word","word" or can it just be
word
word
word
???
I can't seem to get output from the array unless I hard code it into e.g. array("wedding", "BS");
Thank you all for any help! It would be a nice birthday present 😕