str replace - Php str_replace limit in Array -


$orjinal =$_post['orjinal'];  $false = file_get_contents("false.txt"); $true = file_get_contents("true.txt"); $false1 = explode("\n", $false); $true1 = explode("\n", $true); $new = str_replace($false1, $true1, $orjinal);  

working changes 2 times same words

false.txt" apple melon  true.txt melon strawberry  $orjinal="i eating apple" 

i want output; "i eating melon" output ; "i eating strawberry"

you have 3 options:

1. fix false.txt , true.txt:

false.txt:

apple 

true.txt:

melon 

2. call str_replace() twice (or needed):

$new = str_replace($false1, $true1, $orjinal); $new = str_replace($false1, $true1, $new); 

3. sit , think once more want achieve , if simple str_replace() works way intended or not.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -