I get trouble on replacing the word into special characters
First, I read the txt file and store each line into $line and put the special character that I want to change into $table array.
How do I change $line with special character $table array one by one based on the position for example, the txt include three words:
pads
password
qwerty
so the program should show
p@ds
p@d$
p@ssword
p@$sword
p@$$word
p@$$w0rd
qwerty
Now my work just change all special characters into a new word. but how to change it using foreach / for loop one by one based on the position My code as follows
<?php
$file = fopen("text.txt", "r");
while(!feof($file)) {
$line = fgets($file);
$line = rtrim ($line);
$table = array(
'a'=>'@', 'o'=>'0', 's'=>'$',
);
$length = strlen($line);
for ($i=0 ; $i<$length ; $i++){
$line = strtr ($line, $table);
echo $line."<br>";
};
}
fclose($file);
?>